Changeset 1794

Show
Ignore:
Timestamp:
11/19/07 19:20:05 (6 years ago)
Author:
amachang
Message:

lang/javascript/javascript-xpath/trunk: released 0.1.7 (added config and fix compressed version)

Location:
lang/javascript/javascript-xpath/trunk
Files:
4 added
1 removed
10 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/javascript-xpath/trunk/ChangeLog

    r1776 r1794  
     1== 0.1.7 / 2007-11-19  amachang <seijro@gmail.com> 
     2 
     3        * added config 'exportInstaller' (default value is false) 
     4        * added config 'useNative' (default value is true) 
     5        * added functional/dist-test.html and functional/dist-cmp-test.html 
     6        * fixed codes to pass the compress tool 
     7 
    18== 0.1.6 / 2007-11-14  amachang <seijro@gmail.com> 
    29 
  • lang/javascript/javascript-xpath/trunk/Makefile

    r1781 r1794  
    1818 
    1919SRC_FILES = ${SRC_DIR}/head.js\ 
    20         ${SRC_DIR}/config.js\ 
    2120        ${SRC_DIR}/global_decls.js\ 
    2221        ${SRC_DIR}/uai.js\ 
     
    4948FUNCTEST_ORIGINAL = ${FUNC_TEST_DIR}/index.html 
    5049FUNCTEST_ANALYZE = ${FUNC_TEST_DIR}/analyze-test.html 
     50FUNCTEST_DIST_TEMPLATE = ${FUNC_TEST_DIR}/dist-test-template.html 
     51FUNCTEST_DIST = ${FUNC_TEST_DIR}/dist-test.html 
     52FUNCTEST_DIST_CMP = ${FUNC_TEST_DIR}/dist-cmp-test.html 
    5153 
    5254FUNCTEST_NOXHR = ${FUNC_TEST_DIR}/index-no-xhr.html 
     
    5961        @@echo "JavaScript-XPath build complete" 
    6062 
    61 jsxpath: ${JSXPATH_CMP} ${TESTDATA_LOCALJS} ${FUNCTEST_NOXHR} ${FUNCTEST_ANALYZE_NOXHR} 
     63jsxpath: ${JSXPATH_CMP} ${TESTDATA_LOCALJS} ${FUNCTEST_NOXHR} ${FUNCTEST_ANALYZE_NOXHR} ${FUNCTEST_DIST} ${FUNCTEST_DIST_CMP} 
     64 
    6265 
    6366${DIST_DIR}: 
     
    7376${FUNCTEST_ANALYZE_NOXHR}: 
    7477        @@sed -e "s/<!--LOCAL_DATA_HERE-->/<script type=\"text\/javascript\" src=\"\.\/testdatas.js\"><\/script>/g" ${FUNCTEST_ANALYZE} > $@ 
     78 
     79${FUNCTEST_DIST}: 
     80        @@cat ${FUNCTEST_DIST_TEMPLATE} | sed s/@VERSION/${VER}/ > $@ 
     81 
     82${FUNCTEST_DIST_CMP}: 
     83        @@cat ${FUNCTEST_DIST_TEMPLATE} | sed s/@VERSION/${VER}-cmp/ > $@ 
    7584 
    7685${JSXPATH}: ${DIST_DIR} ${VERSION_FILE} ${SRC_FILES} Makefile 
     
    98107        @@rm ${FUNCTEST_NOXHR} 
    99108        @@rm ${FUNCTEST_ANALYZE_NOXHR} 
     109        @@rm ${FUNCTEST_DIST} 
     110        @@rm ${FUNCTEST_DIST_CMP} 
    100111        @@rm ${TESTDATA_LOCALJS} 
    101112        @@rm ${DIST_DIR}/* 
  • lang/javascript/javascript-xpath/trunk/release/javascript-xpath-latest-cmp.js

    r1776 r1794  
    1 if(!document.implementation||!document.implementation.hasFeature||!document.implementation.hasFeature("XPath",null))(function(){var ca=void(0);var da={targetFrame:ca,useInnerText:true};var ea;if(window.jsxpath){ea=window.jsxpath;} 
     1(function(){var ca=void(0);var da={targetFrame:ca,exportInstaller:false,useNative:true,useInnerText:true};var ea;if(window.jsxpath){ea=window.jsxpath;} 
    22else{var fa=document.getElementsByTagName('script');var ga=fa[fa.length-1];var ha=ga.src;ea={};var ia=ha.match(/\?(.*)$/);if(ia){var ja=ia[1].split('&');for(var i=0,l=ja.length;i<l;i++){var ka=ja[i];var la=ka.split('=');var ma=la[0];var na=la[1];if(configValue==ca){configValue==true;} 
    33else if(configValue=='false'||/^-?d+$/.test(configValue)){configValue=eval(configValue);} 
    44ea[ma]=configValue;}}} 
    5 for(var n in da){if(!(n in ea))ea[n]=da[n]} 
     5for(var n in da){if(!(n in ea))ea[n]=da[n];} 
     6ea.hasNative=!!(document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature("XPath",null));if(ea.hasNative&&ea.useNative&&!ea.exportInstaller){return;} 
    67var oa;var pa;var qa;var ra;var sa;var ta;var va;var wa;var xa;var ya;var za;var Aa;var Ba;var Ca;var Da=new function(){var ua=navigator.userAgent;if(RegExp==ca){if(ua.indexOf("Opera")>=0){this.opera=true;} 
    78else if(ua.indexOf("Netscape")>=0){this.netscape=true;} 
     
    132133var Ad=xd.sourceIndex;@*/if((wd.notOnlyElement&&wd.type==0)||wd.name=='*'){for(var i=0,l=zd.length;i<l;i++){var Bd=zd[i];n/*@cc_on @if(@_jscript)if(Bd.nodeValue){yd.push(new cd(Bd,xd,Ad));}@else @*/ 
    133134yd.push(Bd);/*@end @*/}} 
    134 else{var Bd=zd.getNamedItem(wd.name)n/*@cc_on @if(@_jscript)if(Bd&&Bd.nodeValue){Bd=new cd(Bd,xd,Ad);;@else @*/ 
     135else{var Bd=zd.getNamedItem(wd.name);n/*@cc_on @if(@_jscript)if(Bd&&Bd.nodeValue){Bd=new cd(Bd,xd,Ad);;@else @*/ 
    135136if(Bd){/*@end @*/ 
    136137yd.push(Bd);}}} 
     
    278279return Yf.nodes[Zf++];/*@end @*/};} 
    279280else{var Zf=0;return function(){var ag=Yf.length-(Zf++)-1;if(Yf.only&&ag==0)return Yf.only;n/*@cc_on @if(@_jscript)var bg=Yf.nodes[ag];if(bg)return bg.node;return ca;@else @*/ 
    280 return Yf.nodes[ag];/*@end @*/};}};var cg=function(dg){dg=dg||this;dg.XPathExpression=function(eg){if(!eg.length){throw Error('no expression');} 
    281 var fg=this.lexer=Ea(eg);if(fg.empty()){throw Error('no expression');} 
    282 this.expr=oa.parse(fg);if(!fg.empty()){throw Error('bad token: '+fg.next());}};dg.XPathExpression.prototype.evaluate=function(gg,hg){return new XPathResult(this.expr.evaluate(new Ia(gg)),hg);};dg.XPathResult=function(ig,jg){if(jg==0){switch(typeof ig){case 'object':jg++;case 'boolean':jg++;case 'string':jg++;case 'number':jg++;}} 
    283 this.resultType=jg;switch(jg){case 1:this.numberValue=ig.isNodeSet?ig.number():+ig;return;case 2:this.stringValue=ig.isNodeSet?ig.string():''+ig;return;case 3:this.booleanValue=ig.isNodeSet?ig.bool():!!ig;return;case 4:case 5:case 6:case 7:this.nodes=ig.list();this.snapshotLength=ig.length;this.index=0;this.invalidIteratorState=false;break;case 8:case 9:this.singleNodeValue=ig.first();return;}};dg.XPathResult.prototype.iterateNext=function(){return this.nodes[this.index++]};dg.XPathResult.prototype.snapshotItem=function(i){return this.nodes[i]};dg.XPathResult.ANY_TYPE=0;dg.XPathResult.NUMBER_TYPE=1;dg.XPathResult.STRING_TYPE=2;dg.XPathResult.BOOLEAN_TYPE=3;dg.XPathResult.UNORDERED_NODE_ITERATOR_TYPE=4;dg.XPathResult.ORDERED_NODE_ITERATOR_TYPE=5;dg.XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE=6;dg.XPathResult.ORDERED_NODE_SNAPSHOT_TYPE=7;dg.XPathResult.ANY_UNORDERED_NODE_TYPE=8;dg.XPathResult.FIRST_ORDERED_NODE_TYPE=9;dg.document.createExpression=function(kg){return new XPathExpression(kg,null);};dg.document.evaluate=function(lg,mg,_,ng){return document.createExpression(lg,null).evaluate(mg,ng);};};var og;if(ea.targetFrame){var pg=document.getElementById(ea.targetFrame);if(pg)og=pg.contentWindow;} 
    284 cg(og||window);})(); 
     281return Yf.nodes[ag];/*@end @*/};}};var cg=function(dg){dg=dg||this;var eg=dg.document;var ca=dg.undefined;dg.XPathExpression=function(fg){if(!fg.length){throw dg.Error('no expression');} 
     282var gg=this.lexer=Ea(fg);if(gg.empty()){throw dg.Error('no expression');} 
     283this.expr=oa.parse(gg);if(!gg.empty()){throw dg.Error('bad token: '+gg.next());}};dg.XPathExpression.prototype.evaluate=function(hg,ig){return new dg.XPathResult(this.expr.evaluate(new Ia(hg)),ig);};dg.XPathResult=function(jg,kg){if(kg==0){switch(typeof jg){case 'object':kg++;case 'boolean':kg++;case 'string':kg++;case 'number':kg++;}} 
     284this.resultType=kg;switch(kg){case 1:this.numberValue=jg.isNodeSet?jg.number():+jg;return;case 2:this.stringValue=jg.isNodeSet?jg.string():''+jg;return;case 3:this.booleanValue=jg.isNodeSet?jg.bool():!!jg;return;case 4:case 5:case 6:case 7:this.nodes=jg.list();this.snapshotLength=jg.length;this.index=0;this.invalidIteratorState=false;break;case 8:case 9:this.singleNodeValue=jg.first();return;}};dg.XPathResult.prototype.iterateNext=function(){return this.nodes[this.index++]};dg.XPathResult.prototype.snapshotItem=function(i){return this.nodes[i]};dg.XPathResult.ANY_TYPE=0;dg.XPathResult.NUMBER_TYPE=1;dg.XPathResult.STRING_TYPE=2;dg.XPathResult.BOOLEAN_TYPE=3;dg.XPathResult.UNORDERED_NODE_ITERATOR_TYPE=4;dg.XPathResult.ORDERED_NODE_ITERATOR_TYPE=5;dg.XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE=6;dg.XPathResult.ORDERED_NODE_SNAPSHOT_TYPE=7;dg.XPathResult.ANY_UNORDERED_NODE_TYPE=8;dg.XPathResult.FIRST_ORDERED_NODE_TYPE=9;eg.createExpression=function(lg){return new dg.XPathExpression(lg,null);};eg.evaluate=function(mg,ng,_,og){return eg.createExpression(mg,null).evaluate(ng,og);};};var pg;if(ea.targetFrame){var qg=document.getElementById(ea.targetFrame);if(qg)pg=qg.contentWindow;} 
     285if(ea.exportInstaller){window.install=cg;} 
     286if(!ea.hasNative||!ea.useNative){cg(pg||window);}})(); 
  • lang/javascript/javascript-xpath/trunk/release/javascript-xpath-latest.js

    r1776 r1794  
    1 /*  JavaScript-XPath 0.1.6 
     1/*  JavaScript-XPath 0.1.7 
    22 *  (c) 2007 Cybozu Labs, Inc. 
    33 * 
     
    77/*--------------------------------------------------------------------------*/ 
    88 
    9 if (!document.implementation 
    10                 || !document.implementation.hasFeature 
    11                 || !document.implementation.hasFeature("XPath", null)) (function() { 
     9 
     10 
     11(function () { 
    1212 
    1313var undefined = void(0); 
    14  
    1514 
    1615var defaultConfig = { 
    1716    targetFrame: undefined, 
     17    exportInstaller: false, 
     18    useNative: true, 
    1819    useInnerText: true 
    1920}; 
     
    4950 
    5051for (var n in defaultConfig) { 
    51     if (!(n in config)) config[n] = defaultConfig[n] 
     52    if (!(n in config)) config[n] = defaultConfig[n]; 
    5253} 
     54 
     55config.hasNative = !!(document.implementation 
     56                        && document.implementation.hasFeature 
     57                        && document.implementation.hasFeature("XPath", null)); 
     58 
     59if (config.hasNative && config.useNative && !config.exportInstaller) { 
     60    return; 
     61} 
     62 
    5363 
    5464 
     
    12551265            } 
    12561266            else { 
    1257                 var attr = attrs.getNamedItem(test.name) 
     1267                var attr = attrs.getNamedItem(test.name); 
    12581268                 
    12591269/*@cc_on @if (@_jscript) 
     
    26962706 
    26972707    win = win || this; 
     2708    var doc = win.document; 
     2709    var undefined = win.undefined; 
    26982710 
    26992711    win.XPathExpression = function(expr) { 
    27002712        if (!expr.length) { 
    2701             throw Error('no expression'); 
     2713            throw win.Error('no expression'); 
    27022714        } 
    27032715        var lexer = this.lexer = Lexer(expr); 
    27042716        if (lexer.empty()) { 
    2705             throw Error('no expression'); 
     2717            throw win.Error('no expression'); 
    27062718        } 
    27072719        this.expr = BinaryExpr.parse(lexer); 
    27082720        if (!lexer.empty()) { 
    2709             throw Error('bad token: ' + lexer.next()); 
     2721            throw win.Error('bad token: ' + lexer.next()); 
    27102722        } 
    27112723    }; 
    27122724     
    27132725    win.XPathExpression.prototype.evaluate = function(node, type) { 
    2714         return new XPathResult(this.expr.evaluate(new Ctx(node)), type); 
     2726        return new win.XPathResult(this.expr.evaluate(new Ctx(node)), type); 
    27152727    }; 
    27162728     
     
    27642776     
    27652777     
    2766     win.document.createExpression = function(expr) { 
    2767         return new XPathExpression(expr, null); 
     2778    doc.createExpression = function(expr) { 
     2779        return new win.XPathExpression(expr, null); 
    27682780    }; 
    27692781     
    2770     win.document.evaluate = function(expr, context, _, type) { 
    2771         return document.createExpression(expr, null).evaluate(context, type); 
     2782    doc.evaluate = function(expr, context, _, type) { 
     2783        return doc.createExpression(expr, null).evaluate(context, type); 
    27722784    }; 
    27732785}; 
     
    27802792} 
    27812793 
    2782 install(win || window); 
     2794if (config.exportInstaller) { 
     2795    window.install = install; 
     2796} 
     2797 
     2798if (!config.hasNative || !config.useNative) { 
     2799    install(win || window); 
     2800} 
     2801 
    27832802 
    27842803})(); 
  • lang/javascript/javascript-xpath/trunk/src/api.js

    r1269 r1794  
    33 
    44    win = win || this; 
     5    var doc = win.document; 
     6    var undefined = win.undefined; 
    57 
    68    win.XPathExpression = function(expr) { 
    79        if (!expr.length) { 
    8             throw Error('no expression'); 
     10            throw win.Error('no expression'); 
    911        } 
    1012        var lexer = this.lexer = Lexer(expr); 
    1113        if (lexer.empty()) { 
    12             throw Error('no expression'); 
     14            throw win.Error('no expression'); 
    1315        } 
    1416        this.expr = BinaryExpr.parse(lexer); 
    1517        if (!lexer.empty()) { 
    16             throw Error('bad token: ' + lexer.next()); 
     18            throw win.Error('bad token: ' + lexer.next()); 
    1719        } 
    1820    }; 
    1921     
    2022    win.XPathExpression.prototype.evaluate = function(node, type) { 
    21         return new XPathResult(this.expr.evaluate(new Ctx(node)), type); 
     23        return new win.XPathResult(this.expr.evaluate(new Ctx(node)), type); 
    2224    }; 
    2325     
     
    7173     
    7274     
    73     win.document.createExpression = function(expr) { 
    74         return new XPathExpression(expr, null); 
     75    doc.createExpression = function(expr) { 
     76        return new win.XPathExpression(expr, null); 
    7577    }; 
    7678     
    77     win.document.evaluate = function(expr, context, _, type) { 
    78         return document.createExpression(expr, null).evaluate(context, type); 
     79    doc.evaluate = function(expr, context, _, type) { 
     80        return doc.createExpression(expr, null).evaluate(context, type); 
    7981    }; 
    8082}; 
     
    8789} 
    8890 
    89 install(win || window); 
     91if (config.exportInstaller) { 
     92    window.install = install; 
     93} 
    9094 
     95if (!config.hasNative || !config.useNative) { 
     96    install(win || window); 
     97} 
     98 
     99 
  • lang/javascript/javascript-xpath/trunk/src/head.js

    r1269 r1794  
    77/*--------------------------------------------------------------------------*/ 
    88 
    9 if (!document.implementation 
    10                 || !document.implementation.hasFeature 
    11                 || !document.implementation.hasFeature("XPath", null)) (function() { 
     9 
     10 
     11(function () { 
    1212 
    1313var undefined = void(0); 
    1414 
     15var defaultConfig = { 
     16    targetFrame: undefined, 
     17    exportInstaller: false, 
     18    useNative: true, 
     19    useInnerText: true 
     20}; 
     21 
     22var config; 
     23 
     24if (window.jsxpath) { 
     25    config = window.jsxpath; 
     26} 
     27else { 
     28    var scriptElms = document.getElementsByTagName('script'); 
     29    var scriptElm = scriptElms[scriptElms.length - 1]; 
     30    var scriptSrc = scriptElm.src; 
     31    config = {}; 
     32    var scriptSrcMatchResult = scriptSrc.match(/\?(.*)$/); 
     33    if (scriptSrcMatchResult) { 
     34        var configStrings = scriptSrcMatchResult[1].split('&'); 
     35        for (var i = 0, l = configStrings.length; i < l; i ++) { 
     36            var configString = configStrings[i]; 
     37            var configStringSplited = configString.split('='); 
     38            var configName = configStringSplited[0]; 
     39            var convigValue = configStringSplited[1]; 
     40            if (configValue == undefined) { 
     41                configValue == true; 
     42            } 
     43            else if (configValue == 'false' || /^-?d+$/.test(configValue)) { 
     44                configValue = eval(configValue); 
     45            } 
     46            config[configName] = configValue; 
     47        } 
     48    } 
     49} 
     50 
     51for (var n in defaultConfig) { 
     52    if (!(n in config)) config[n] = defaultConfig[n]; 
     53} 
     54 
     55config.hasNative = !!(document.implementation 
     56                        && document.implementation.hasFeature 
     57                        && document.implementation.hasFeature("XPath", null)); 
     58 
     59if (config.hasNative && config.useNative && !config.exportInstaller) { 
     60    return; 
     61} 
     62 
     63 
  • lang/javascript/javascript-xpath/trunk/src/stepExpr.js

    r1776 r1794  
    340340            } 
    341341            else { 
    342                 var attr = attrs.getNamedItem(test.name) 
     342                var attr = attrs.getNamedItem(test.name); 
    343343                 
    344344/*@cc_on @if (@_jscript) 
  • lang/javascript/javascript-xpath/trunk/test/functional/analyze-test.html

    r1722 r1794  
    1212  <!--LOCAL_DATA_HERE--> 
    1313 
    14   <script type="text/javascript" src="../../src/config.js"></script> 
     14  <script type="text/javascript" src="./config.js"></script> 
    1515  <script type="text/javascript" src="../../src/uai.js"></script> 
    1616  <script type="text/javascript" src="../../src/lexer.js"></script> 
  • lang/javascript/javascript-xpath/trunk/test/functional/index.html

    r1549 r1794  
    1111  <!--LOCAL_DATA_HERE--> 
    1212 
    13   <script type="text/javascript" src="../../src/config.js"></script> 
     13  <script type="text/javascript" src="./config.js"></script> 
    1414  <script type="text/javascript" src="../../src/uai.js"></script> 
    1515  <script type="text/javascript" src="../../src/lexer.js"></script> 
  • lang/javascript/javascript-xpath/trunk/version.txt

    r1776 r1794  
    1 0.1.6 
     10.1.7