<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 165, comments - 198, trackbacks - 0, articles - 1
      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

    2008年9月11日


    學(xué)習(xí)就從官方的測試開始,但不知道怎么回事官方的測試有問題,這我就把我配置的簡單junit環(huán)境共享給大家把!
    1.下載 hibernate-annotations-3.4.0.GA 并解壓 ,cd 到解壓后目錄下
    2. $>ant junit (天知道,怎么官方出的東西測試不能通過!!)
    ?? 不要急,我們來看錯誤 (錯誤提示有刪減)
    ???? 錯誤-1:$>build.xml:95: ./jdbc not found.
    ???? 解決辦法-1: $>mkdir ./jdbc
    3.? $>ant junit
    ???? 錯誤-2:?
    ????? ./build.xml:124: The following error occurred while executing this line:
    ????? ./build.xml:126: The following error occurred while executing this line:
    ????? ./common-build.xml:349: .\src\filters\hsqldb.filter as it doesn't exist.
    ???? 解決辦法-2:
    ?????? $>mkdir? ./src/filters ;
    ?????? $>echo "" > ./src/filters/hsqldb.filter;
    4. ? $>ant junit
    ???? 錯誤-3:
    ?????? ./build.xml:124: The following error occurred while executing this line:
    ?????? ./build.xml:126: The following error occurred while executing this line:
    ?????? ./common-build.xml:351: .\src\test-resources not found.
    ????? $>mkdir? ./src/test-resources ;
    5. ? $>ant junit
    ???? 錯誤-4:沒有ant 錯誤了!,但測試都為錯誤,那我們就看看 第一個測試吧,找下原因!
    ???????? test-resources:
    ????????? [mkdir] Created dir: hibernate-anntations-3.4.0.GA\build\test-reports\hsqldb
    ????????? [echo] Running against db: hsqldb
    ????????? [junit] Running org.hibernate.test.annotations.ConfigurationTest
    ????????? [junit] Tests run: 7, Failures: 0, Errors: 6, Time elapsed: 1.218 sec
    ????????? .............
    ???? $>find . -name "ConfigurationTest.java"? #pwd /hibernate-anntations-3.4.0.GA
    ??????? ./test/org/hibernate/test/annotations/configuration/ConfigurationTest.java
    ??????? ./test/org/hibernate/test/annotations/ConfigurationTest.java
    ????? 根據(jù)路徑 org.hibernate.test.annotations.ConfigurationTest
    ????? gvim? ./test/org/hibernate/test/annotations/ConfigurationTest.java
    ????? 發(fā)現(xiàn)第20行: cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" );
    ????? 感覺應(yīng)該沒有配置 jdbc
    ????? gvim ./test/org/hibernate/test/annotations/hibernate.cfg.xml? #果然 沒配置
    ????? 我這就放個我的簡單配置上來(使用 hbm hsqldb 內(nèi)存數(shù)據(jù)庫測 試 ):
    <!DOCTYPE?hibernate-configuration?PUBLIC
    ????????"-//Hibernate/Hibernate?Configuration?DTD?3.0//EN"
    ????????"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"
    >
    <hibernate-configuration>
    ??
    <session-factory>
    ????????
    <property?name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
    ????????
    <property?name="connection.driver_class">org.hsqldb.jdbcDriver</property>
    ????????
    <property?name="connection.url">jdbc:hsqldb:mem:hbn_ann</property>
    ????????
    <property?name="connection.username">sa</property>
    ????????
    <property?name="connection.password"></property>
    ???
    ????????
    <mapping?resource="org/hibernate/test/annotations/Boat.hbm.xml"/>
    ????????
    <mapping?package="org.hibernate.test.annotations"/>
    ????????
    <mapping?class="org.hibernate.test.annotations.Plane"/>
    ??
    </session-factory>
    </hibernate-configuration>


    ????? 我這就是要hsqldb吧,既然上面錯誤1有 jdbc 文件夾,那就是放 jdbc jar 的地方
    ????? $> cp ../hsqldb.jar? ./jdbc
    ???
    6. ? $>ant junit
    ???? 呵呵 測試 第一個正確了 ! (目前配置后,測試環(huán)境并不是全部都正確,比如第2個測試)
    ???? 其他測試錯誤日志在??? .\build\test-reports\hsqldb ...
    ???? 比如第2個錯誤 異常部分
    ????? org.hibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect.
    ??? at org.hibernate.dialect.Dialect.instantiateDialect(Dialect.java:256)
    ??? at org.hibernate.dialect.Dialect.getDialect(Dialect.java:234)
    ??????? ........ 大家一邊學(xué)習(xí),一邊配置測試 環(huán)境吧。
    ??? 錯誤日記 都會在 build\test-reports\hsqldb下

    posted @ 2009-04-14 11:30 G_G 閱讀(1689) | 評論 (0)編輯 收藏


    參考:
    http://tech.ddvip.com/2008-12/122835390597191.html


    頁面可以直接運行:
    <html>
    <head>

    <style?type="text/css">

    .box1
    {
    float
    :left;
    width
    :21px;
    height
    :21px;
    position
    :relative;
    background
    :?#F3F2E2?url(http://mp3.youdao.com/images/mbox_bg.gif)?no-repeat;
    }
    .box1?
    {
    background-position
    :?0px?-60px;
    }


    </style>

    </head>

    <body>

    ????
    <div?class="box1"?
    ????????onmouseover
    ="this.style.backgroundPosition='0px?-81px'?"?
    ????????onmouseout
    ="this.style.backgroundPosition='0px?-102px'?"????
    ????
    >
    ????
    </div>

    </body>

    </html>

    posted @ 2009-02-24 16:46 G_G 閱讀(2001) | 評論 (0)編輯 收藏

    javascript 學(xué)習(xí)
    ?? ? ? javascript 大體上可分為3個不同部分組成: 核心(ECMAscript),文本對象(DOM),瀏覽器對象(BOM)
      1. ?核心(ECMAscript): 關(guān)鍵字,語句,運算符,對象
      2. 文本對象(DOM):DOM將把整個頁面規(guī)劃成由節(jié)點層級構(gòu)成的文檔.
        1. 解析遵循 W3C html dom 標準
        2. ? W3C dom 參考特別關(guān)注 DOM Node 說明???
      3. BOM 瀏覽器對象.? cookie,彈出新瀏覽器,瀏覽器設(shè)置大小
    ?
    核心(ECMAscript)Global 內(nèi)置對象;
    ????? 方法: parseInt(),isNan(),encodeURI()...等都為此對象方法
    ????? 特別注意 eval();動態(tài)語言的象征 比如:eval("alert('hi')"); 但這個方法很邪惡(安全方面)
    文本對象(DOM)說明:
    ?? ??? ?
    <bookstore>
    <book category="cooking">
    <title lang="en">Everyday Italian</title>
    <author>Giada De Laurentiis</author>
    <year>2005</year>
    <price>30.00</price>
    </book>
    </bookstore>

    DOM node tree

    Node tree

    ?? ??? ??? ???


    ??? ?

    ? 1. ECMAscript基礎(chǔ)

    ?????? $ 變量弱類型 ; ??? 匈牙利類型標示 : var iOuouValue=100;?

    ?????? $ 結(jié)束行分號有無都可以; ??? 但再 onsubmit="javascript:function();return false;"

    ?????? $ 關(guān)鍵字 ; 提別注意

    ??????????????? "constructor" bean.constructor

    ???????????????????? //print bean function(){

    ????????????????????????? ....

    ????????????????????? }

    ??????????????? "typeof" ? var test=1; alert(typeof testX); //output "undefined"

    ??????????????? "NaN" - not a number ->? isNan("blue"); //output "true" ? ->isNan("123"); //output "false"?

    ?????? $ 對象; var o = new Object(); var a = {}?

    ?? ??? ??? ??? ?這里特別說明下 我們普通寫的 一個 function 就是一個 object?

    ?? ??? ??? ?? 這?? var a = {name:"劉凱毅"} 等同與 var a = function(){this.name="劉凱毅"};

    ?? ??? ??? ??? ???? 來個 {name:"test",pass:"123456",addr:"bj"} //這是什么 ?! json

    ?? ??? ??? ???????? 當 var str = '{name:"test",pass:"123456",addr:"bj"}'

    ?? ??? ??? ??? ???? var objectBean = eval(str); //這里就是 對象 objectBea.name 使用了

    ? 域概念:

    <SCRIPT type=text/javascript>
    var sMessage = 'Hello';
    function setSomething() {
    ? sColor = 'red';
    ? sMessage = 'Hello World!';
    }
    setSomething();
    alert(sMessage); //Hello World!
    alert(sColor); //red
    </SCRIPT>
    <SCRIPT type=text/javascript>
    var sMessage = 'Hello';
    function setSomething() {
    ? var sColor = 'red';
    ? sMessage = 'Hello World!';
    }
    setSomething();
    alert(sMessage); //Hello World!
    alert(sColor); // 什么都沒有
    </SCRIPT>

    <SCRIPT type=text/javascript>
    var sMessage = 'Hello';
    function setSomething() {
    ? var sColor = 'red';
    ? var sMessage = 'Hello World!';
    }
    setSomething();
    alert(sMessage); //Hello
    alert(sColor); // 什么都沒有
    </SCRIPT>

    ??????????

    為面向?qū)ο笞龌A(chǔ):object prototype 類型的對象應(yīng)用。參考

    // 最簡單的 繼承
    Object.prototype.inObj?=?1;

    function?A()
    {
    ????this.inA?=?2;
    }
    ?
    A.prototype.inAProto?=?3;
    ?
    B.prototype?=?new?A;????????????//?Hook?up?A?into?B's?prototype?chain
    B.prototype.constructor?=?B;
    function?B()
    {
    ????this.inB?=?4;
    }
    ?
    B.prototype.inBProto?=?5;
    ?
    x?=?new?B;
    document.write(x.inObj?+?',?'?+?x.inA?+?',?'?+?x.inAProto?+?',?'?+?x.inB?+?',?'?+?x.inBProto);

    //1, 2, 3, 4, 5
    //增加點信心 http://www.json.org/json.js
    Object.prototype.toJSONString = function (filter) {
    return JSON.stringify(this, filter);
    };
    后我們就可以使用 bean.toJSONString()不是嗎?

    ??? $ arguments ;

    ???????? function getFun(){alert(arguments.length);}?? ;

    ?

    ?? ??? ??? ??? ?getFun("xx") //output 1

    ?? ??? ??? ??? ?getFun("xx",23) //output 2



    ?? $ 語句 ;特殊說明下 for?

    ?????????? for(var i=0i<iCount;i++)?? 或 for( attr in object ) ;

    ?????????? 如果無聊 你可以 for( sProp in window ){alert(sProp+"你丫點啊!");} //看看 javascript 的反射

    ??????????????

    ? ? ? ? ? ? ? ??

    ???


    面向?qū)ο螅?/b>

    ? var bean = new Bean();

    ??

    ? 1.工廠方法

    ??????? ??? function getAttr(){

    ???? ?? ??? ???? alert(this.attr)

    ??????????? }

    ??????????? function Bean(tattr){

    ?? ??? ??? ???? var bean = new Object;

    ?? ??? ??? ?????bean.attr = tattr;

    ?? ??? ??? ?????bean.getAttr = getAttr;

    ?? ??? ??? ???? return bean ;

    ??????????? }

    ?? ???? 根本就是山寨版 面向?qū)ο?br />

    ? 2.構(gòu)造

    ????? ??? function Bean(tattr){

    ?? ??? ?????? this.attr = tattr ;

    ?? ??? ??? ?? bean.getAttr = function(){

    ?? ??? ??? ?????alert(this.attr);

    ?? ??? ??? ? ?} ? ?

    ?? ??? ???}

    ?? 其上 2 總 再Bean 對象創(chuàng)建時,方法會 “重復(fù)生成函數(shù)”!


    ? 3.原型模式

    ??? function Bean(){}

    ??? Bean.prototype.attr = "";

    ??? Bean.prototype.getAttr=function(){alert(this.attr);}

    ?? ?

    ?? 解決 “重復(fù)生成函數(shù)” 問題,但新的問題 Bean.prototype.getArray = new Array();


    ?? 其 new 對象 bean1 和 bean2 都會共享 new Array 空間(是我們不想看到的)


    ? 4.混合 模型 :)? 哈哈

    ???? function Bean(){

    ?? ??? ?this.attr= "";

    ?? ??? ?this.getArray=new Array;

    ?? ?}

    ?? ?Bean.prototype.getAttr=function(){alert(this.attr);}

    ?

    ? 5.動態(tài)原型 (注意下面開始,就是真正的面向?qū)ο?/span>!!!)

    ?? ??? function Bean(){

    ?? ???? this.attr= "";
    ?? ??? ?this.getArray=new Array;

    ?? ???? //classload 加載 時

    ?? ???? if(typeof Bean._initialized == "undefined" ){

    ?? ??? ???? Bean.prototype.getAttr=function(){alert(this.attr);};

    ?? ???? ??? Bean._initialized= true ;

    ?? ??? ?}

    ???? }

    ???

    /****************************************************************/

    對象繼承

    ? 1.對象冒充!!(可支持多繼承,山寨很強大)

    ????? function classA(sstr){

    ?? ???? this.color = sstr ;

    ?? ???? this.sayColor = function(){

    ?? ??? ???? alert(this.color);

    ?? ??? ?};

    ?? ???}

    ?? ?? function classC(){}

    ?? ??? function classB(){

    ?? ??? ???? this.newMethod =ClassA ;

    ?? ??? ???? this.newMethod();

    ?? ??? ???? delete this.newMethod ;


    ?? ??? ???? this.newMethod =ClassC ;

    ?? ??? ???? this.newMethod();

    ?? ??? ???? delete this.newMethod ;

    ?? ??? ????

    ?? ??? ???? this.arrt = "google";

    ?? ??? ?}

    ?? ?

    ? 2.call() apply() 也山寨,

    ????? function classA(sstr){

    ?? ???? this.color = sstr ;

    ?? ???? this.sayColor = function(str){

    ?? ??? ???? alert(str+this.color);

    ?? ??? ?};

    ?? ???}

    ?? ??? function classB(){

    ?? ??? ??? // this.newMethod =ClassA ;

    ?? ??? ??? // this.newMethod();

    ?? ??? ??? // delete this.newMethod ;

    ?? ??? ???? classA.call(this,"red");

    ?? ??? ???? //classA.apply(this,new Array("red"))

    ?? ??? ???? this.arrt = "baidu";

    ?? ??? }


    3.正統(tǒng)的繼承 原型鏈 (但不支持多繼承)
    ??? function classA(){this.oo="test";}
    ??? classA.prototype.color = "red";
    ??? function classB(){}
    ??? classB.prototype = new classA ;
    ??? classB.prototype.sayName = function(){
    ?? ???? alert( this.color );
    ?? ?}
    ?? ?
    var bb = new classB ;
    ?? ?bb.sayName();
    // output red
    ?? ?
    alert(bb.oo); // output test

    ?? ?alert( bb instanceof classA); //output true
    ?? ?alert( bb instanceof classB); //output? true

    4.如果你要多繼承!!并且還支持 instanceof
    ?? ???? 混合方式:
    ?? ???? function classA(){}
    ?? ???? function classB(){}
    ?? ???? function classC(){
    ?? ??? ???? classA.call(this);
    ?? ??? ???? classC.call(this);
    ?? ??? ?}
    ?? ???? classC.prototype = new classA ;//注意 這
    instanceof 只能對 A有用

    ?? ??? ?






    ???

    posted @ 2009-02-12 11:56 G_G 閱讀(1848) | 評論 (2)編輯 收藏



    下載:flash-plugin-10.0.15.3-release.i386.rpm

    ?rpm -ivh flash-plugin-10.0.15.3-release.i386.rpm

    posted @ 2009-01-12 23:39 G_G 閱讀(754) | 評論 (0)編輯 收藏


    tomcat > server.xml

    ????? <Host name="localhost" appBase="webapps"
    ?????? unpackWARs="true" autoDeploy="true"
    ?????? xmlValidation="false" xmlNamespaceAware="false">

    ? <Context docBase="D:/workspace/meganotes/mn_mod_admin/target/mn_mod_admin/" path="/"? />

    。。。。


    關(guān)鍵:在Context上不要加reloadable和debug屬性
    ?然后 使用eclipse tomcat 調(diào)試
    ok

    posted @ 2008-12-26 17:52 G_G 閱讀(540) | 評論 (0)編輯 收藏


    <? xml?version="1.0"?encoding="UTF-8" ?>
    < project? name ="ssh" >
    ????
    < property? file ="ssh.properties" ? />
    ????
    < tstamp >
    ????????
    < format? property ="TODAY" ?pattern ="yyyyMMddHHmm" ? />
    ????
    </ tstamp >
    ????
    < property? name ="ssh.path" ?value ="/data/meganotes/shell/" ? />


    ????
    < target? name ="shell/?文件?上載/覆蓋" >
    ????????
    < input? addproperty ="scp_coverage_shell_file"
    ????????????message
    ="輸入(ssh/?下文件名?\n\r?上載或覆蓋?到服務(wù)器?218?${ssh.path}?):" >
    ????????
    </ input >
    ????????
    < input
    ????????????
    message ="請確定是否使用?ssh/${scp_coverage_shell_file}?覆蓋服務(wù)器中?${ssh.host}:${ssh.path}${scp_coverage_shell_file}?(y,n)"
    ????????????validargs
    ="y,n" ?addproperty ="do.coverage" ?defaultvalue ="n" ? />
    ????????
    < condition? property ="do.abort" >
    ????????????
    < equals? arg1 ="n" ?arg2 ="${do.coverage}" ? />
    ????????
    </ condition >
    ????????
    < fail? if ="do.abort" > 退出 </ fail >

    ????????
    < sshexec? host ="${ssh.host}" ?username ="${ssh.myName}"
    ????????????password
    ="${ssh.myPass}" ?trust ="true"
    ????????????command
    ="
    ????????????????????mkdir?-p?${ssh.path}backup/${TODAY}?;
    ????????????????????if?[?-f?${ssh.path}${scp_coverage_shell_file}???]?;
    ????????????????????then??
    ????????????????????????cp?${ssh.path}${scp_coverage_shell_file}?${ssh.path}backup/${TODAY}/?;
    ????????????????????fi?;
    ????????"
    >
    ????????
    </ sshexec >
    ????????
    < scp? file ="ssh/${scp_coverage_shell_file}"
    ????????????todir
    ="${ssh.myName}:${ssh.myPass}@${ssh.host}:${ssh.path}"
    ????????????trust
    ="true" ?verbose ="true" ? />

    ????????
    < sshexec? host ="${ssh.host}" ?username ="${ssh.myName}"
    ????????????password
    ="${ssh.myPass}" ?trust ="true"
    ????????????command
    ="chmod?777?${ssh.path}${scp_coverage_shell_file}" >
    ????????
    </ sshexec >
    ????
    </ target >

    ????
    < target? name ="shell/?文件查看" >
    ????????
    < input? addproperty ="show_shell_file" ?message ="輸入查看文件名(*sh):"
    ????????????defaultvalue
    ="*" >
    ????????
    </ input >
    ????????
    < sshexec? host ="${ssh.host}" ?username ="${ssh.myName}"
    ????????????password
    ="${ssh.myPass}" ?trust ="true"
    ????????????command
    ="ls??/data/meganotes/shell/${show_shell_file}" >
    ????????
    </ sshexec >
    ????
    </ target >

    ????
    < target? name ="shell/?文件拷貝" >
    ????????
    < input? addproperty ="scp_shell_file"
    ????????????message
    ="輸入?/data/meganotes/shell/?下需要文件名(cp?到?ssh?下):" >
    ????????
    </ input >
    ????????
    < scp
    ????????????
    file ="${ssh.myName}:${ssh.myPass}@${ssh.host}:/data/meganotes/shell/${scp_shell_file}"
    ????????????todir
    ="ssh" ?trust ="true" ?verbose ="true" ? />
    ????
    </ target >



    ????
    < target? name ="admin-mvn組合操作" >
    ????????
    < exec? executable ="cmd" >
    ????????????
    < arg? value ="/c" ? />
    ????????????
    < arg? value ="${basedir}/sh/mvn/meganotes_mvn_clear.bat" ? />
    ????????
    </ exec >
    ????????
    < exec? executable ="cmd" >
    ????????????
    < arg? value ="/c" ? />
    ????????????
    < arg? value ="${basedir}/sh/mvn/meganotes_mvn_install.bat" ? />
    ????????
    </ exec >
    ????????
    < exec? executable ="cmd" >
    ????????????
    < arg? value ="/c" ? />
    ????????????
    < arg? value ="${basedir}/sh/mvn/mn_mod_admin_mvn_intall.bat" ? />
    ????????
    </ exec >
    ????
    </ target >


    ????
    < target? name ="admin-tomcat日志" >
    ????????
    < sshexec? host ="${ssh.host}" ?username ="${ssh.myName}"
    ????????????password
    ="${ssh.myPass}" ?trust ="true" ?command ="${ssh.adminRunLog}" >
    ????????
    </ sshexec >
    ????
    </ target >

    ????
    < target? name ="schedule-tomcat日志" >
    ????????
    < sshexec? host ="${ssh.host}" ?username ="${ssh.myName}"
    ????????????password
    ="${ssh.myPass}" ?trust ="true"
    ????????????command
    ="${ssh.scheduleRunLog}" >
    ????????
    </ sshexec >
    ????
    </ target >
    ????
    < target? name ="查找2008/下Mp3沒轉(zhuǎn)128-64文件夾" >
    ????????
    < sshexec? host ="${ssh.host}" ?username ="${ssh.myName}"
    ????????????password
    ="${ssh.myPass}" ?trust ="true" ?command ="${ssh.64k}" >
    ????????
    </ sshexec >
    ????????
    < sshexec? host ="${ssh.host}" ?username ="${ssh.myName}"
    ????????????password
    ="${ssh.myPass}" ?trust ="true" ?command ="${ssh.128k}" >
    ????????
    </ sshexec >
    ????????
    < sshexec? host ="${ssh.host}" ?username ="${ssh.myName}"
    ????????????password
    ="${ssh.myPass}" ?trust ="true"
    ????????????command
    ="${ssh.128kto64k.err}" >
    ????????
    </ sshexec >
    ????
    </ target >

    ????
    < target? name ="admin模塊測試" >
    ????????
    < input? addproperty ="admin_test_input"
    ????????????message
    ="測試類輸入(Video*Test):" ?defaultvalue ="*Test" >
    ????????
    </ input >
    ????????
    < echo? message ="${admin_test_input}" ></ echo >
    ????????
    < exec? executable ="cmd" >
    ????????????
    < arg? value ="/c" ? />
    ????????????
    < arg
    ????????????????
    value ="${basedir}/sh/admin_test.bat?${admin_test_input}?" ? />
    ????????
    </ exec >
    ????
    </ target >
    </ project >

    posted @ 2008-12-24 16:24 G_G 閱讀(6400) | 評論 (3)編輯 收藏





    ???? public ? static ? void ?main(String[]?args)? {
    ????????
    try ? {
    ????????
    ?????????String?charset?
    = ? " UTF-8 " ;
    ?????????String?outfile?
    = ? " d:\\category.20081218.gz " ;
    ?????????BufferedReader?in?
    = ? new ?BufferedReader(
    ??????????
    new ?InputStreamReader(
    ??????????
    new ?FileInputStream( " d:\\category.20081218 " ),
    ??????????charset));
    ??????????
    ??????????BufferedOutputStream?out?
    =
    ????????????
    new ?BufferedOutputStream(
    ??????????????
    new ?GZIPOutputStream(
    ????????????????
    new ?FileOutputStream(outfile)));
    ??????????
    ??????????
    ??????????System.out.println(
    " Writing?file " );
    ??????????String?c;
    ??????????
    while ((c? = ?in.readLine()) != null )
    ????????????out.write(?(c
    + " \n " ).getBytes(charset));
    ??????????in.close();
    ??????????out.close();
    ??????????System.out.println(
    " Reading?file " );
    ??????????BufferedReader?in2?
    =
    ????????????
    new ?BufferedReader(
    ??????????????
    new ?InputStreamReader(
    ????????????????
    new ?GZIPInputStream(
    ??????????????????
    new ?FileInputStream(outfile)
    ??????????????????),charset
    ????????????????)
    ??????????????);
    ??????????String?s;
    ??????????
    while ((s? = ?in2.readLine())? != ? null )
    ????????????System.out.println(s);
    ????????}
    ? catch (Exception?e)? {
    ??????????e.printStackTrace();
    ????????}

    ??????}


    posted @ 2008-12-22 14:35 G_G 閱讀(3628) | 評論 (0)編輯 收藏



    官方上下
    http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/

    $.補全中文? 修改
    ??? jquery.autocomplete.js 中
    ??? $input.bind(($.browser.opera ? "keypress" : "keydown")
    ??? 改為
    ??? $input.bind(($.browser.opera ? "keypress" : "keyup")
    ????
    $. 在 localdata.js 》》 var cities = [..?
    ?? 中放些 中文 測試吧


    測試頁面 ,最簡單的使用頁面 。(應(yīng)該算是最簡單補全測試了)
    <script?type="text/javascript"?src="../lib/jquery.js"></script>
    <script?type='text/javascript'?src='../jquery.autocomplete.js'></script>

    <link?rel="stylesheet"?type="text/css"?href="../jquery.autocomplete.css"?/>
    <script?type="text/javascript">
    $().ready(
    function()?{
    ????$(
    "#suggest1").autocomplete([
    ????
    "test1",
    ????
    "test2",
    ????
    "測試1",
    ???????
    "測試2"
    ????]);
    });
    </script>

    <input?type="text"?id="suggest1"?/>



    使用json

    <script?type="text/javascript"?src="../lib/jquery.js"></script>
    <script?type='text/javascript'?src='../jquery.autocomplete.js'></script>

    <script?type='text/javascript'?src='localdata.js'></script>
    <link?rel="stylesheet"?type="text/css"?href="../jquery.autocomplete.css"?/>
    <script?type="text/javascript">
    var?emails?=?[
    ????{?name:?
    "Peter?Pan",?to:?"peter@pan.de"?},
    ????{?name:?
    "Molly",?to:?"molly@yahoo.com"?},
    ????{?name:?
    "Forneria?Marconi",?to:?"live@japan.jp"?},
    ????{?name:?
    "Master?<em>Sync</em>",?to:?"205bw@samsung.com"?},
    ????{?name:?
    "Dr.?<strong>Tech</strong>?de?Log",?to:?"g15@logitech.com"?},
    ????{?name:?
    "Don?Corleone",?to:?"don@vegas.com"?},
    ????{?name:?
    "Mc?Chick",?to:?"info@donalds.org"?},
    ????{?name:?
    "Donnie?Darko",?to:?"dd@timeshift.info"?},
    ????{?name:?
    "Quake?The?Net",?to:?"webmaster@quakenet.org"?},
    ????{?name:?
    "Dr.?Write",?to:?"write@writable.com"?}
    ]


    $().ready(
    function()?{
    ????????$(
    "#suggest13").autocomplete(emails,?{
    ????????
    //補全中選擇顯示
    ????????formatItem:?function(row,?i,?max)?{
    ????????????
    return?i?+?"/"?+?max?+?":?\""?+?row.name?+?"\"?["?+?row.to?+?"]";
    ????????????},
    ????????
    //補全匹配格式
    ????????formatMatch:?function(row,?i,?max)?{
    ????????????
    return?row.name?;
    ????????????},
    ????????
    //補全選定后顯示
    ????????formatResult:?function(row)?{
    ????????????
    return?row.to;
    ????????}
    ????})
    });
    </script>




    posted @ 2008-12-13 09:41 G_G 閱讀(1120) | 評論 (1)編輯 收藏

    不要為 拼寫 ajax url 而郁悶了。希望能對大家有幫助。

    /*?
    ??? 1.form?ajax?使用:
    ????eG:
    form就是普通的 html form
    ????????<input?type="button"?value="xx"?onclick="formAjax('data.jsp',this.form,ajaxReturn)"/>
    ????????function?ajaxReturn(data){
    ????????????document.getElementById("div1").innerHTML?=??data?;
    ????????}
    ??
    ????
    ??? 2.ajax?使用???:
    ????AjaxFunction
    ????????AjaxFunction('url?param=tt&param2=te',function(text){??
    ????????????alert(text);
    ????????});

    ??? 3.迭代器:

    ??? recursiveNodes(array,dom,pushFun,layer)
    ? ? ?? array 迭代寄存器
    ? ? ?? dom 被迭代對象
    ?????? pushFun 自定義收集方法
    ??????????? pushFun(array,node,layer)
    ?????????????? node 迭代中對象
    ?????? layer 深度
    ??? EG:
    ??? var arr = [] ;
    ??? recursiveNodes(
    arr ,dom,function(array,node,layer){
    ??????????? arr.push(node);
    ???? },2)
    ;


    ? ? ???
    ?*/
    var?_request;
    try?{
    ????
    this._request?=?new?XMLHttpRequest();
    }?
    catch?(e)?{
    ????
    try?{
    ????????
    this._request?=?new?ActiveXObject('Msxml2.XMLHTTP');
    ????}?
    catch?(e)?{
    ????????
    try?{
    ????????????
    this._request?=?new?ActiveXObject('Microsoft.XMLHTTP');
    ????????}?
    catch?(e)?{
    ????????????request?
    =?false;
    ????????}
    ????}
    }

    var?AjaxFunction?=?function(urls,?getAjaxText)?{
    ????AjaxFunction._getAjaxText?
    =?null;

    ????_url?
    =?'';
    ????_params?
    =?'';

    ????AjaxFunction._getAjaxText?
    =?getAjaxText;
    ????
    var?strs?=?urls.split(/\?/);
    ????_url?
    =?strs[0];
    ????
    if?(strs.length?>?1)
    ????????_params?
    =?strs[1];

    ????_request.open(
    "POST",?this._url,?true);
    ????_request.setRequestHeader(
    "Cache-Control",?"no-cache");
    ????_request.setRequestHeader(
    "content-type",
    ????????????
    "application/x-www-form-urlencoded");
    ????_request.send(_params);
    ????_request.onreadystatechange?
    =?_onComplete;
    };
    function?_onComplete()?{
    ????
    if?(_request.readyState?==?4)?{
    ????????
    if?(_request.status?==?200?||?_request.status?==?0)?{
    ????????????
    if?(_request.responseText?!=?null?&&?_request.responseText?!=?''
    ????????????????????
    &&?_request.responseText?!=?'?')
    ????????????????AjaxFunction._getAjaxText(_request.responseText);
    ????????}
    ????}
    }

    /*
    ?*?迭代?1.?array,dom?2.?array,dom,layer
    ?
    */
    function?recursiveNodes(array,?dom,?pushFun,?layer)?{
    ????
    if?(layer?==?0)
    ????????
    return;
    ????
    if?(layer?>?0)?{
    ????????
    --layer;
    ????????
    if?(dom.hasChildNodes?&&?dom.hasChildNodes())?{
    ????????????
    for?(?var?i?=?0;?i?<?dom.childNodes.length;?i++)?{
    ????????????????
    var?nodeT?=?dom.childNodes.item(i);
    ????????????????
    if?(typeof?pushFun?==?"function")
    ????????????????????pushFun(array,nodeT,?layer);
    ????????????????
    else
    ????????????????????array.push(nodeT);
    ????????????????recursiveNodes(array,?dom.childNodes.item(i),?pushFun,?layer);
    ????????????}
    ????????}?
    else
    ????????????
    return;
    ????}?
    else?if?(layer?<?0)?{
    ????????
    ++layer;
    ????????
    var?nodeT?=?dom.parentNode;
    ????????
    if?(nodeT)?{
    ????????????
    if?(typeof?pushFun?==?"function")?{
    ????????????????pushFun(array,nodeT,?layer);
    ????????????}?
    else?{
    ????????????????array.push(nodeT);
    ????????????}
    ????????????recursiveNodes(array,?dom.parentNode,?pushFun,?layer)
    ????????}?
    else
    ????????????
    return;
    ????}
    }

    function?formAjax(url,ttform,returnFun){
    ????
    var?datas?=?[];
    ????
    var?arr?=?['input','select'];
    ????recursiveNodes(datas,ttform,
    function(array,node,layer){
    ????????
    for(var?i=0;i<arr.length;i++){
    ????????????
    if(?node.getAttribute?){
    ????????????????
    var?paramName?=?node.getAttribute('name')?;
    ????????????????
    if(?/select/i.test(?node.nodeName?)?){
    ????????????????????array.push(paramName
    +'='+node.options[node.selectedIndex].value);
    ????????????????}
    else?if(?paramName?!=null?&&??/^\s*(\w+)\s*$/g.test(paramName)?&&?new?RegExp(arr[i],'i').test(node.nodeName)??){
    ????????????????????array.push(paramName
    +'='+node.value);
    ????????????????}
    ????????????}
    ????????}
    ????},
    999);
    ????
    //??&#63;
    ????//&?&#38;
    ????var?urls?=?url+'?'+datas.join("&");
    ????AjaxFunction(urls,returnFun);
    }




    posted @ 2008-11-09 18:35 G_G 閱讀(1827) | 評論 (0)編輯 收藏


    function trim(str){ return str.replace(/(^\s*)|(\s*$)/g,""); }

    function recursiveNodes(array,dom,layer){
    ? if( layer==0 ) return ;
    ? if(layer>0){
    ???? --layer;
    ???? if( dom.hasChildNodes && dom.hasChildNodes() ){
    ?????? for(var i=0;i<dom.childNodes.length;i++ ){
    ????? array.push(dom.childNodes.item(i));
    ????????? recursiveNodes(array, dom.childNodes.item(i),layer ) ;
    ?????? }
    ???? }else return? ;
    ? }else if(layer<0){
    ???? ++layer;
    ???? if( dom.parentNode ){
    ?????????? array.push( dom.parentNode );
    ?????????? recursiveNodes( array,dom.parentNode,layer)
    ???? }else return ;
    ? }
    }

    /*
    [@name || && > < >= <= != @location='UK']
    */
    function singleStep(dom,stepAction,stepStr){
    ? var allArrData = [] ;
    ? var arrData = [] ;
    ? var num = stepAction.split(/\//).length ;
    ? recursiveNodes(allArrData,dom,num==2?1:999);
    ?
    ? stepStr = trim(stepStr) ;
    ? var nodeName? ;
    ? var nodeNum ;
    ? var conds = true ;
    ???? //判斷單匹配 是否有 屬性對比? [@..=..]
    ? if( /\[(.*?)\]/.test(stepStr) ){
    ????? nodeName = trim( /.*?(?=\[{1})/g.exec(stepStr)[0]?? ).replace(/\*/g,".*") ;
    ????? conds = /\[(.*?)\]/.exec(stepStr)[1].replace(/\*/g,".*") ;
    ????? if(! isNaN(conds) ){
    ??? nodeNum = parseInt(conds)-1;

    ????? }else{
    ????? //屬性 替換為
    ??????? conds = conds.replace(/(@)(.*?)(?=\W)/g," allArrData[i].getAttribute('$2') ") ;
    ??????? conds = conds.replace( /([\W]+)(.*?)::\'(.*?)\'/g," $1 /$3/g.test($2) " ) ;
    ??????? conds = conds.replace( /(text\(\))/g ," allArrData[i].innerHTML ") ;
    ??????? conds = conds.replace( /([\w\s])(=)/g ,"$2=") ;

    ????? }
    ? }else{
    ????? nodeName = stepStr ;
    ? }

    ? for(var j=i=0;i<allArrData.length;i++){
    ???? if(? eval('/'+nodeName+'/i.test( allArrData[i].nodeName ) ')?? ){
    ??? if(typeof nodeNum=="number"){
    ??? ? if(j==nodeNum){ arrData.push( allArrData[i] );? return arrData; }
    ??? ? else ??? ++j;
    ??? }else if( eval(' allArrData[i].getAttribute && '+conds) ){
    ????????? arrData.push( allArrData[i] );
    ??????? }
    ???? }
    ? }
    ? return arrData ;
    }


    function getXpath(dom,xpathStr){
    ?? var xpaths = xpathStr.split(/(\/{1,2})/g);
    ??? var arrDom = [dom] ;
    ?? for(var i=1;i<xpaths.length;i=i+2){
    ??????? var arrData = [];
    ??????? for(var j=0;j<arrDom.length;j++)
    ????????? arrData = arrData.concat( singleStep(arrDom[j],xpaths[i],xpaths[i+1]) );
    ??????? arrDom = arrData ;
    ?? }
    ?? return arrDom ;
    }

















    ******************************************************************************************************
    function trim(str){ return str.replace(/(^\s*)|(\s*$)/g,""); }

    function recursiveNodes(array,dom,layer){
    ? if( layer==0 ) return ;
    ? if(layer>0){
    ???? --layer;
    ???? if( dom.hasChildNodes && dom.hasChildNodes() ){
    ?????? for(var i=0;i<dom.childNodes.length;i++ ){
    ????? array.push(dom.childNodes.item(i));
    ????????? recursiveNodes(array, dom.childNodes.item(i),layer ) ;
    ?????? }
    ???? }else return? ;
    ? }else if(layer<0){
    ???? ++layer;
    ???? if( dom.parentNode ){
    ?????????? array.push( dom.parentNode );
    ?????????? recursiveNodes( array,dom.parentNode,layer)
    ???? }else return ;
    ? }

    }



    /*
    ? [@name || && > < >= <= != @location='UK']
    */
    function singleStep(dom,stepAction,stepStr){
    ? var allArrData = [] ;
    ? var arrData = [] ;
    ? var num = stepAction.split(/\//).length ;
    ? recursiveNodes(allArrData,dom,num==2?1:999);
    ?
    ? stepStr = trim(stepStr) ;
    ? var nodeName? ;
    ? var conds = true ;
    ???? //判斷單匹配 是否有 屬性對比? [@..=..]
    ? if( /\[(.*?)\]/.test(stepStr) ){
    ????? nodeName = trim( /^(.*?)\[{1}/.exec(stepStr)[1] ) ;
    ?????????????? //屬性 替換為
    ????? conds = /\[(.*?)\]/.exec(stepStr)[1].replace(/(@)(.*?)(?=\W)/g," allArrData[i].getAttribute('$2').toString() ") ;
    ????? conds = conds.replace( /([\W]+)(.*?)::\'(.*?)\'/g," $1 /$3/g.test($2) " ) ;
    ??????? conds = conds.replace( /(text\(\))/g ," allArrData[i].innerHTML ") ;
    ????? conds = conds.replace( /([\w\s])(=)/g ,"$2=") ;
    ? }else{
    ????? nodeName = stepStr ;
    ???? }

    ? for(var i=0;i<allArrData.length;i++){
    ???? if(? new RegExp(nodeName, 'i').test( allArrData[i].nodeName ) && eval(conds) ){
    ???????? arrData.push( allArrData[i] );
    ???????????? }
    ? }
    ? return arrData ;
    }


    function getXpath(dom,xpathStr){
    ?? var xpaths = xpathStr.split(/(\/{1,2})/g);
    ??? var arrDom = [dom] ;
    ?? for(var i=1;i<xpaths.length;i=i+2){
    ??????? var arrData = [];
    ??????? for(var j=0;j<arrDom.length;j++)
    ????????? arrData = arrData.concat( singleStep(arrDom[j],xpaths[i],xpaths[i+1]) );
    ??????? arrDom = arrData ;
    ?? }
    ?? return arrDom ;
    }

    posted @ 2008-09-24 19:57 G_G 閱讀(520) | 評論 (0)編輯 收藏


    Python is a dynamic object-oriented programming language that can be used for many kinds of software development.

    It offers strong support for integration with other languages and tools, comes with extensive standard libraries, and can be learned in a few days.
    offers 提出
    integration 綜合
    extensive 寬廣
    standard libraries 標準庫


    Many Python programmers report substantial productivity gains and feel the language encourages the development of higher quality, more maintainable code.
    report 宣告
    substantial 實質(zhì)
    productivity 生產(chǎn)力

    posted @ 2008-09-23 09:56 G_G 閱讀(205) | 評論 (1)編輯 收藏

    直接 運行 div_show_drag.rar
    http://www.tkk7.com/Files/Good-Game/div_Show_drag.rar

    html test
    <html>
    <head>

    <script?type="text/javascript"?src="showDivUtil.js"></script>

    </head>

    <body>

    <input?type="button"?id="_in"?value="google-baidu"?onclick="test();"/>
    <div?id='_div'?/>
    <script?language="javascript">
    /*api說明
    ????ShowDiv(?源element?,?是否使用現(xiàn)有?div?)
    ????????源element,是否使用現(xiàn)有?div?都可為null?;
    */
    var?ediv?=?new?ShowDiv('_in',null);

    function?test(){
    ????
    if(?!?ediv.isShow?){
    ????????
    // tdiv[X,Y,H,W]準備展現(xiàn)div set->tdiv.X = ..? ? ,
    ??????? // tsubEle[X,Y,H,W]
    ??????? // 源ele大小位置??,tscreen[
    screenH,screenW]屏幕長寬
    ????????ediv.setLocation?=?function(tdiv,tsubEle,tscreen){
    ????????????
    /*??居中展現(xiàn)
    ?????????????tdiv.W?=200?;
    ?????????????tdiv.H?=?300?;
    ?????????????tdiv.X?=?tscreen.screenW/2-tdiv.W/2?;
    ?????????????tdiv.Y?=?tscreen.screenH/2-tdiv.H/2?;
    ????????????
    */

    ?????????????
    /*??根據(jù)?tsubEle?位置?左顯示
    ????????????tdiv.X?=?tsubEle.X+tsubEle.W?;
    ????????????tdiv.Y?=?tsubEle.Y?;
    ?????????????
    */

    ??????????????
    /*??根據(jù)?tsubEle?大小??左長條?顯示?
    ?????????????tdiv.X?=?tsubEle.X+tsubEle.W?;
    ?????????????tdiv.Y?=?tsubEle.Y?;
    ?????????????
    */
    ????????????
    ????????
    ??????????????
    /*??根據(jù)?tsubEle?大小??下長條?顯示
    ?????????????tdiv.X?=?tsubEle.X+tsubEle.W?;
    ?????????????tdiv.Y?=?tsubEle.Y?;
    ?????????????tdiv.H?=?200?;
    ?????????????tdiv.W?=?tsubEle.W?;
    ?????????????
    */
    ????????????
    ????????????
    /*??..?等等?自己嘗試吧*/
    ????????????tdiv.innerHTML?
    =?"<li>google</li><li>baidu</li>"?;
    ????????????
    //可以參考?
    ????????????Drag.init(tdiv);
    ????????}????
    ????????ediv.setStyle('background
    -color:#F4F4F4;');
    ????????ediv.show();
    ????}
    else{
    ????????ediv.close();
    ????????
    //ediv.delete();
    ????}
    }

    </script>
    </body>
    </html>



    showDivUtil.js

    /*
    * Skynet
    *? 2008-9-15 00:56
    *?? liukaiyi@gmail.com
    */

    function?ShowDiv(subEle,ediv){
    ????
    //public?
    ????this.style??;
    ????
    this.isShow?=?false?;

    ????
    //private?
    ????this._div??;
    ????
    this._subEle??;
    ????
    this._subEle??;


    ????????
    if(?typeof?ediv?==?"undefined"?||?ediv?==?null)?
    ????????????
    this._div=document.createElement("div");
    ????????
    else?if(?typeof?ediv?==?"string")?
    ????????????
    this._div=document.getElementById(ediv);????
    ????????
    else?if(??/object/.test(typeof?ediv)?)
    ????????????
    this._div=?ediv?;
    ????????
    ????????
    if(?typeof?subEle?==?"string")?
    ????????????
    this._subEle=document.getElementById(subEle);????
    ????????
    else?if(??/object/.test(typeof?subEle)?)
    ????????????
    this._subEle=?subEle?;

    }

    ????
    //外置方法?x?,?y?,w?,?h?,?div
    ????ShowDiv.prototype.setLocation?=?new?Function()?;

    ????
    //設(shè)置?div?樣式
    ????ShowDiv.prototype.setStyle=function(styleStrOrObj){
    ????????
    this.style=this._div.style?;
    ????????
    if(?typeof?styleStrOrObj?==?"string"){
    ????????????
    var?strs?=?styleStrOrObj.split(/;/)?;
    ????????????
    for(var?i=0;i<strs.length;i++){
    ????????????????
    var?key?=?strs[i].split(/:/)[0];
    ????????????????
    var?value?=?strs[i].split(/:/)[1];
    ????????????????
    var?_s?=?key.indexOf("-")?;
    ????????????????
    if(?_s>0)?
    ????????????????????key
    =key.substring(0,_s)+key.substring(_s+1,_s+2).toLocaleUpperCase()+key.substring(_s+2,key.length);
    ????????????????
    if(?key!=null&&key!=''&&key!='?'?){
    ????????????????????eval(?'
    this._div.style.'+key+'="'+value+'"'?);
    ????????????????}
    ????????????}
    ????????}
    else?if(??/object/.test(typeof?styleStrOrObj)?)?{
    ????????????
    this._div.style?=?styleStrOrObj?;
    ????????}
    ????????
    if(this._div.style.position==null?||?this._div.style.position=="")
    ????????????
    this._div.style.position="absolute";
    ????}
    ????
    ????ShowDiv.prototype.show
    =function(){
    ????????
    if(?typeof?this._subEle?!=?"undefined"?||?this._subEle?!=?null){
    ????????????
    this._subEle.Y?=?getElementPos(this._subEle).y;
    ????????????
    this._subEle.X?=?getElementPos(this._subEle).x?;
    ????????????
    this._subEle.W?=?this._subEle.offsetWidth?;
    ????????????
    this._subEle.H?=?this._subEle.offsetHeight?;
    ????????}
    ????????
    //this._div.Y?=?sset
    ????????//this._div.X?=?sset
    ????????this._div.W?=?parseInt(?this._div.style.width?);
    ????????
    this._div.H?=?parseInt(?this._div.style.height?);
    ????????
    ????????
    this.setLocation(this._div,this._subEle,{screenW:document.body.clientWidth,screenH:document.body.clientHeight});
    ????????
    this._div.style.left?=?this._div.X??;
    ????????
    this._div.style.top?=?this._div.Y?;
    ????????
    ????????
    if(?this._div.W?&&?this._div.H?){
    ????????????
    this._div.style.width?=?this._div.W?;
    ????????????
    this._div.style.height?=?this._div.H?;
    ????????}
    ????????document.body.appendChild(
    this._div);
    ????????
    this.isShow?=?true?;
    ????}

    ????ShowDiv.prototype.close
    =function(){
    ????????document.body.removeChild(
    this._div);?
    ????????
    this.isShow?=?false?;
    ????}

    ?????ShowDiv.prototype.
    delete=function(){
    ????????document.body.removeChild(
    this._div);?
    ????????
    this._div?=?null?;
    ????????
    this.isShow?=?false?;
    ????}

    ?
    //得到 Element 位置
    //?說明:用?Javascript?獲取指定頁面元素的位置
    //
    ?整理:http://www.codebit.cn
    //
    ?來源:YUI?DOM
    function?getElementPos(el)?{
    ????
    var?ua?=?navigator.userAgent.toLowerCase();
    ????
    var?isOpera?=?(ua.indexOf('opera')?!=?-1);
    ????
    var?isIE?=?(ua.indexOf('msie')?!=?-1?&&?!isOpera);?//?not?opera?spoof
    ????if(el.parentNode?===?null?||?el.style.display?==?'none'){
    ????????
    return?false;
    ????}
    ????
    var?parent?=?null;
    ????
    var?pos?=?[];
    ????
    var?box;

    ????
    if(el.getBoundingClientRect){
    ????
    //?IE?
    ????????box?=?el.getBoundingClientRect();
    ????????
    var?scrollTop?=?Math.max(document.documentElement.scrollTop,?document.body.scrollTop);
    ????????
    var?scrollLeft?=?Math.max(document.documentElement.scrollLeft,?document.body.scrollLeft);
    ????????
    return?{x:box.left?+?scrollLeft,?y:box.top?+?scrollTop};
    ????}
    else?if(document.getBoxObjectFor){
    ?????
    //?gecko
    ????????box?=?document.getBoxObjectFor(el);
    ????????
    var?borderLeft?=?(el.style.borderLeftWidth)?parseInt(el.style.borderLeftWidth):0;
    ????????
    var?borderTop?=?(el.style.borderTopWidth)?parseInt(el.style.borderTopWidth):0;
    ????????pos?
    =?[box.x?-?borderLeft,?box.y?-?borderTop];
    ????}
    else?{
    ?????
    //?safari?&?opera
    ????????pos?=?[el.offsetLeft,?el.offsetTop];
    ????????parent?
    =?el.offsetParent;
    ????????
    if?(parent?!=?el)?{
    ????????????
    while?(parent)?{
    ????????????????pos[
    0]?+=?parent.offsetLeft;
    ????????????????pos[
    1]?+=?parent.offsetTop;
    ????????????????parent?
    =?parent.offsetParent;
    ????????????}
    ????????}
    ?????????
    if?(ua.indexOf('opera')?!=?-1||?(?ua.indexOf('safari')?!=?-1?&&?el.style.position?==?'absolute'?)){
    ????????????pos[
    0]?-=?document.body.offsetLeft;
    ????????????pos[
    1]?-=?document.body.offsetTop;
    ????????}
    ????}
    ?
    ????
    if?(el.parentNode)?{?parent?=?el.parentNode;?}
    ????
    else?{?parent?=?null;?}
    ?
    ?
    ????
    //?account?for?any?scrolled?ancestors
    ?????while?(parent?&&?parent.tagName?!=?'BODY'?&&?parent.tagName?!=?'HTML'){?????
    ????????pos[
    0]?-=?parent.scrollLeft;
    ????????pos[
    1]?-=?parent.scrollTop;
    ????????
    if?(parent.parentNode)?{?parent?=?parent.parentNode;?}
    ????????
    else?{?parent?=?null;?}
    ????}
    ????
    return?{x:pos[0],?y:pos[1]};
    }?




    posted @ 2008-09-15 01:02 G_G 閱讀(439) | 評論 (0)編輯 收藏


    上面加上我的注解(希望能對大家理解有幫助):
    /**************************************************
    ?*?dom-drag.js
    ?*?09.25.2001
    ?*?www.youngpup.net
    ?*?Script?featured?on?Dynamic?Drive?(
    http://www.dynamicdrive.com)?12.08.2005
    ?**************************************************
    ?*?10.28.2001?-?fixed?minor?bug?where?events
    ?*?sometimes?fired?off?the?handle,?not?the?root.
    ???*????注解:??Skynet
    ?*????email?:?liukaiyi@gmail.com
    ?*????????blog?:?www.tkk7.com/Good-Game
    ?*************************************************
    */

    var?Drag?
    =?{

    ????obj?:?
    null,
    ????
    ????
    /*?api?說明:?
    ????*?????方法調(diào)用可以參考:
    http://www.dynamicdrive.com/dynamicindex11/domdrag/
    ????*?????????o?拖拽?Handle?
    ????*????????oRoot?被拖拽?element??(可選,?默認不填?o為被拖拽對象??type=object)
    ????*????????minX,?maxX,?minY,?maxY?限制拖拽范圍?(可選,默認不填為全屏?type=int?)
    ????*?????????bSwapHorzRef,?bSwapVertRef?判斷是否允許?橫,縱向拖拽(可選,默認不填無限制?type=boolean?)
    ????*?????fXMapper(x),?fYMapper(y)??為外置函數(shù)?拖拽效果體現(xiàn)前調(diào)用?(x,y)?為當前element位置(可選?type=Function)
    ????
    */
    ????init?:?function(o,?oRoot,?minX,?maxX,?minY,?maxY,?bSwapHorzRef,?bSwapVertRef,?fXMapper,?fYMapper)
    ????{
    ????????
    /*?拖拽事件?掛載??(本js?主線?生命周期?描述)
    ????????*????1.?預(yù)定?o.onmousedown事件觸發(fā)運行??Drag.start。
    ????????*????2.?觸發(fā)?element->?onmousedown->Drag.start
    ????????*????????2.1????先得到?element?當前"改變初"位置,記入到?o.lastMouseX?;o.lastMouseY,掛載Drag.obj,Darp.root?為當前?element。
    ????????*????????2.2?????預(yù)定?document.onmousemove????=?Drag.drag;?document.onmouseup?=?Drag.end。
    ????????*????3.??觸發(fā)?document.onmousemove?運行?Drag.drag->?拖拽效果體現(xiàn)。
    ????????*????4.??觸發(fā)?document.onmouseup?運行?Drag.end->?掛載?document.onmousemove;document.onmouseup;Drag.obj取消。
    ????????
    */
    ????????o.onmousedown?
    =?Drag.start;
    ????????
    ????????
    //是否能?橫,縱向拖拽
    ????????o.hmode????????????=?bSwapHorzRef???false?:?true?;
    ????????o.vmode????????????
    =?bSwapVertRef???false?:?true?;
    ????????
    //掛載?o.root?
    ????????o.root?=?oRoot?&&?oRoot?!=?null???oRoot?:?o?;
    ????????
    ????????
    if?(o.hmode??&&?isNaN(parseInt(o.root.style.left??)))?o.root.style.left???=?"0px";
    ????????
    if?(o.vmode??&&?isNaN(parseInt(o.root.style.top???)))?o.root.style.top????=?"0px";
    ????????
    if?(!o.hmode?&&?isNaN(parseInt(o.root.style.right?)))?o.root.style.right??=?"0px";
    ????????
    if?(!o.vmode?&&?isNaN(parseInt(o.root.style.bottom)))?o.root.style.bottom?=?"0px";
    ????????
    ????????
    //?限定?移動范圍
    ????????o.minX????=?typeof?minX?!=?'undefined'???minX?:?null;
    ????????o.minY????
    =?typeof?minY?!=?'undefined'???minY?:?null;
    ????????o.maxX????
    =?typeof?maxX?!=?'undefined'???maxX?:?null;
    ????????o.maxY????
    =?typeof?maxY?!=?'undefined'???maxY?:?null;

    ????????o.xMapper?
    =?fXMapper???fXMapper?:?null;
    ????????o.yMapper?
    =?fYMapper???fYMapper?:?null;
    ????????
    ????????
    /*自定義拖拽-事件添加(相當于我們在java中的?抽象類?中未實現(xiàn)的方法??比如:
    ????????*????obj.onDrag?=?function(x,?y)?{
    ?????????*????????scrolldiv.style.top=y?*?(-1)?+"px";
    ????????*????}
    ????????
    */
    ????????o.root.onDragStart????
    =?new?Function();
    ????????o.root.onDragEnd????
    =?new?Function();
    ????????o.root.onDrag????????
    =?new?Function();
    ????},

    ????
    //由?function?init?>>?o.onmousedown????=?Drag.start;
    ????start?:?function(e)
    ????{
    ????????
    //得到被拖拽?element
    ????????var?o?=?Drag.obj?=?this;
    ????????e?
    =?Drag.fixE(e);
    ????????
    ????????
    //element?移動初位置?
    ????????var?y?=?parseInt(o.vmode???o.root.style.top??:?o.root.style.bottom);
    ????????var?x?
    =?parseInt(o.hmode???o.root.style.left?:?o.root.style.right?);
    ????????
    //可能的外置函數(shù)調(diào)用
    ????????o.root.onDragStart(x,?y);
    ????????
    //event?初位置?記入
    ????????o.lastMouseX????=?e.clientX;
    ????????o.lastMouseY????
    =?e.clientY;
    ????????
    ????????
    if?(o.hmode)?{
    ????????????
    if?(o.minX?!=?null)????o.minMouseX????=?e.clientX?-?x?+?o.minX;
    ????????????
    if?(o.maxX?!=?null)????o.maxMouseX????=?o.minMouseX?+?o.maxX?-?o.minX;
    ????????}?
    else?{
    ????????????
    if?(o.minX?!=?null)?o.maxMouseX?=?-o.minX?+?e.clientX?+?x;
    ????????????
    if?(o.maxX?!=?null)?o.minMouseX?=?-o.maxX?+?e.clientX?+?x;
    ????????}

    ????????
    if?(o.vmode)?{
    ????????????
    if?(o.minY?!=?null)????o.minMouseY????=?e.clientY?-?y?+?o.minY;
    ????????????
    if?(o.maxY?!=?null)????o.maxMouseY????=?o.minMouseY?+?o.maxY?-?o.minY;
    ????????}?
    else?{
    ????????????
    if?(o.minY?!=?null)?o.maxMouseY?=?-o.minY?+?e.clientY?+?y;
    ????????????
    if?(o.maxY?!=?null)?o.minMouseY?=?-o.maxY?+?e.clientY?+?y;
    ????????}
    ????????
    ????????
    /*>>>>>>>>>>>比較關(guān)鍵的掛載<<<<<<<<<<<<<<
    ????????*????
    ????????*????使用?document.onmousemove?事件?而不使用?element的,是應(yīng)為當拖動太快,可能會脫離element.
    ????????
    */
    ????????document.onmousemove????
    =?Drag.drag;
    ????????document.onmouseup????????
    =?Drag.end;

    ????????
    return?false;
    ????},

    ????
    //由?function?start>>?document.onmousemove????=?Drag.drag;
    ????drag?:?function(e)
    ????{
    ????????e?
    =?Drag.fixE(e);
    ????????var?o?
    =?Drag.obj;

    ????????var?ey????
    =?e.clientY;
    ????????var?ex????
    =?e.clientX;
    ????????
    //得到?element?當前位置(vmode,hmode判斷是否可以橫縱向拖拽)
    ????????var?y?=?parseInt(o.vmode???o.root.style.top??:?o.root.style.bottom);
    ????????var?x?
    =?parseInt(o.hmode???o.root.style.left?:?o.root.style.right?);
    ????????var?nx,?ny;
    ????????
    ????????
    if?(o.minX?!=?null)?ex?=?o.hmode???Math.max(ex,?o.minMouseX)?:?Math.min(ex,?o.maxMouseX);
    ????????
    if?(o.maxX?!=?null)?ex?=?o.hmode???Math.min(ex,?o.maxMouseX)?:?Math.max(ex,?o.minMouseX);
    ????????
    if?(o.minY?!=?null)?ey?=?o.vmode???Math.max(ey,?o.minMouseY)?:?Math.min(ey,?o.maxMouseY);
    ????????
    if?(o.maxY?!=?null)?ey?=?o.vmode???Math.min(ey,?o.maxMouseY)?:?Math.max(ey,?o.minMouseY);
    ????????
    ????????
    //本js中?最主要的地方:?
    ????????
    //得到?鼠標移動?向量?drap(x,y)?=?fun_drap:event(x,y)?-?fun_start:event(x,y)
    ????????
    //并于?得到拖拽效果:??element(x,y)?+?drap(x,y)?
    ????????nx?=?x?+?((ex?-?o.lastMouseX)?*?(o.hmode???1?:?-1));
    ????????ny?
    =?y?+?((ey?-?o.lastMouseY)?*?(o.vmode???1?:?-1));

    ????????
    if?(o.xMapper)????????nx?=?o.xMapper(y)
    ????????
    else?if?(o.yMapper)????ny?=?o.yMapper(x)
    ????????
    ????????
    //效果體現(xiàn)
    ????????Drag.obj.root.style[o.hmode???"left"?:?"right"]?=?nx?+?"px";
    ????????Drag.obj.root.style[o.vmode?
    ??"top"?:?"bottom"]?=?ny?+?"px";
    ????????Drag.obj.lastMouseX????
    =?ex;
    ????????Drag.obj.lastMouseY????
    =?ey;
    ????????
    //調(diào)用外置函數(shù)
    ????????Drag.obj.root.onDrag(nx,?ny);
    ????????
    return?false;
    ????},
    ????
    ????
    //由?function?start>>?document.onmouseup????????=?Drag.end;
    ????end?:?function()
    ????{
    ????????document.onmousemove?
    =?null;
    ????????document.onmouseup???
    =?null;
    ????????Drag.obj.root.onDragEnd(????parseInt(Drag.obj.root.style[Drag.obj.hmode?
    ??"left"?:?"right"]),?
    ????????????????????????????????????parseInt(Drag.obj.root.style[Drag.obj.vmode?
    ??"top"?:?"bottom"]));
    ????????Drag.obj?
    =?null;
    ????},
    ????
    ????
    //跨?瀏覽器?得到?event
    ????fixE?:?function(e)
    ????{
    ????????
    if?(typeof?e?==?'undefined')?e?=?window.event;
    ????????
    if?(typeof?e.layerX?==?'undefined')?e.layerX?=?e.offsetX;
    ????????
    if?(typeof?e.layerY?==?'undefined')?e.layerY?=?e.offsetY;
    ????????
    return?e;
    ????}
    };

    posted @ 2008-09-14 11:28 G_G 閱讀(2683) | 評論 (0)編輯 收藏


    參考:
    http://neil-jh.javaeye.com/blog/199345

    效果:
  • google



  • <%@?page?language="java"?contentType="text/html;?charset=UTF-8"
    ????pageEncoding
    ="UTF-8"%>
    <%@taglib?uri="/struts-tags"?prefix="s"%>
    <%@taglib?uri="http://java.sun.com/jstl/core_rt"?prefix="c"%>
    <!DOCTYPE?html?PUBLIC?"-//W3C//DTD?HTML?4.01?Transitional//EN"?"http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    ??
    <meta?http-equiv="Content-Type"?content="text/html;?charset=UTF-8">
    <title>Insert?title?here</title>
    </head>
    <body>
    <li>
    ????
    <!--?類中靜態(tài)變量??-->
    ????
    <s:property?value="%{@action.SsdAction@GOOD}"/>
    ??????
    ????
    <!--?調(diào)用?方法?-->
    ??????
    <s:set?name="num"?value="20"?/>
    ????
    <s:set?name="listData"?value="%{?ssdMethod.getBeans(#num)??}"?/>
    ????
    ????
    <!--?和?jstl?配合使用?-->
    ????
    <select>
    ????????
    <c:forEach?var="btmp"?items="${listData}">
    ????????????
    <option?value="${btmp.id}?}">${btmp.name}</option>
    ????????
    </c:forEach>
    ????
    </select>
    ????
    ????
    <!--?調(diào)用枚舉類?
    ????????public?enum?Type?{
    ????????????//id?value?:?gget?sset?
    ????????????g1(1,"test1"),
    ????????????g2(2,"test2"),
    ????????????g3(3,"test3");
    ????????????.
    ????
    -->
    ????
    <s:select?list="%{?@myEnum.Type@values()?}"?listKey="id"?listValue="value"?/>

    ????
    <!--?循環(huán)遍歷?添加邏輯?..{?#this.id>2?}?-->
    ????
    <s:select?list="%{?@myEnum.Type@values().{?#this.id>2?}?}"?listKey="id"?listValue="value"?/>

    </li>


    </body>
    </html>

    posted @ 2008-09-11 16:04 G_G 閱讀(440) | 評論 (0)編輯 收藏

    主站蜘蛛池模板: 久99精品视频在线观看婷亚洲片国产一区一级在线 | 另类专区另类专区亚洲| 久久久久久AV无码免费网站| 亚洲精品亚洲人成在线观看下载| 中国亚洲呦女专区| 亚洲v高清理论电影| www免费插插视频| 亚洲日本一区二区三区在线不卡| 久久精品国产亚洲av天美18| 免费看又爽又黄禁片视频1000| 亚洲中文无码永久免费| 日韩版码免费福利视频| 亚洲图片激情小说| 每天更新的免费av片在线观看 | 97se亚洲国产综合自在线| 又大又硬又爽又粗又快的视频免费| 五月天网站亚洲小说| 免费人成黄页在线观看日本| 亚洲VA中文字幕无码一二三区| 亚洲国产综合精品中文第一| 成人女人A级毛片免费软件| 亚洲日本久久一区二区va| 毛片A级毛片免费播放| 日韩色日韩视频亚洲网站| 大胆亚洲人体视频| 国产国产人免费人成成免视频| 亚洲综合熟女久久久30p| a级日本高清免费看| 亚洲精品成人av在线| 很黄很色很刺激的视频免费| 色婷婷六月亚洲综合香蕉| 亚洲av午夜成人片精品电影| 国产视频精品免费视频| 亚洲综合国产精品| 女人被免费视频网站| 人碰人碰人成人免费视频| 亚洲精品无码不卡在线播HE| 最近免费最新高清中文字幕韩国| 亚洲毛片网址在线观看中文字幕| 丁香花在线视频观看免费| 四虎永久精品免费观看|