* removed some debug statements
authorMichael Dale <dale@users.mediawiki.org>
Thu, 5 Nov 2009 23:18:12 +0000 (23:18 +0000)
committerMichael Dale <dale@users.mediawiki.org>
Thu, 5 Nov 2009 23:18:12 +0000 (23:18 +0000)
* added more testLang examples

js2/mwEmbed/mv_embed.js
js2/mwEmbed/tests/testLang.html

index c35e692..e23409d 100644 (file)
@@ -371,7 +371,7 @@ if( !mv_embed_path ) {
                 * Plural matchRuleTest
                 */
                function matchRuleTest(cRule, val){
-                       js_log("matchRuleTest:: " + typeof cRule + ' ' + cRule + ' == ' + val );
+                       //js_log("matchRuleTest:: " + typeof cRule + ' ' + cRule + ' == ' + val );
 
                        function checkValue(compare, val){
                                if(typeof compare == 'string'){
@@ -440,12 +440,12 @@ if( !mv_embed_path ) {
                for(var ruleInx in rs){
                        cRule = rs[ruleInx];
                        if( matchRuleTest( cRule, tObj.arg ) ){
-                               js_log("matched rule: " + ruleInx );
+                               //js_log("matched rule: " + ruleInx );
                                return getTempParamFromRuleInx(tObj, rCount );
                        }
                        rCount ++;
                }
-               js_log('no match found for: ' + tObj.arg + ' using last/other : ' +  tObj.param [ tObj.param.length -1 ] );
+               //js_log('no match found for: ' + tObj.arg + ' using last/other : ' +  tObj.param [ tObj.param.length -1 ] );
                //return the last /"other" template param
                return tObj.param [ tObj.param.length -1 ];
        }
@@ -603,7 +603,7 @@ if( !mv_embed_path ) {
                                
                                // ... but I am having fun with recursion so here it is...
                                // or at least mirror: http://www.mediawiki.org/wiki/Extension:Page_Object_Model
-                               function rdpp ( txt , cn){
+                               function rdpp ( txt , cn){                              
                                        var node = {};                                  
                                        //inspect each char
                                        for(var a=0; a < txt.length; a++){
@@ -614,18 +614,18 @@ if( !mv_embed_path ) {
                                                                node['c'] = new Array();
 
                                                        node['c'].push( rdpp( txt.substr( a ), true ) );                                                                                                                                                                                                                                                                                                                                        
-                                               }else if( txt[a] == '}' && txt[a+1] == '}'){
+                                               }else if( txt[a] == '}' && txt[a+1] == '}'){                                                    
+                                                       a=a+2;
                                                        if( !node['p'] ){
                                                                return node;
-                                                       }
-                                                       node = node['p'];
-                                                       a=a+2;
+                                                       }                                                       
+                                                       node = node['p'];                                                       
                                                }
                                                if(!node['t'])
                                                        node['t']='';
-                                               
-                                               if( txt[a] )
-                                                               node['t']+=txt[a];
+                                               //dont put closures into output:
+                                               if( txt[a] &&  txt[a]!='}' )
+                                                               node['t'] += txt[a];
                                                                
                                        }
                                        return node;
@@ -648,7 +648,7 @@ if( !mv_embed_path ) {
                                                tObj["arg"] = tname.split(':').pop();
                                        }
 
-                                       js_log("TNAME::" + tObj["name"] + ' from:: ' + ts);                                             
+                                       //js_log("TNAME::" + tObj["name"] + ' from:: ' + ts);                                           
                                        var pSet = ts.split('\|');
                                        pSet.splice(0,1);                                       
                                        if( pSet.length ){
index f129ce9..d20c098 100644 (file)
@@ -10,7 +10,7 @@ td{
 <script type="text/javascript" >
 var scriptLoaderURID = 't11';
 //for just setting one or two to test at a time for debug
-var langKeyDebug = ['fr'];
+var langKeyDebug = [ 'az', 'da', 'pt', 'fr', 'lv',c 'en'];
 
 //shortLangKey is an array of at least one language from every group in cldrConverter.php
 var langKeyGroups = ['en','az', 'da', 'pt', 'fr', 'lv', 'ga','hr','cy','mk','mt','pl','sl'];
@@ -177,7 +177,7 @@ var langKeyAll = [
 
 js2AddOnloadHook( function(){
        //do mauall script loaders calls to test multiple languages:
-       function doLangTable(langSet){          
+       function doLangTable( langSet ){                
                //build table output: 
                var msgTestSet = {                                                                                              
                        'undelete_short': [ 0, 1, 2, 5, 21, 30 ],                       
@@ -192,11 +192,11 @@ js2AddOnloadHook( function(){
                var passTest=0;
                var failTest=0;
                var testCount=0;        
-               $j.each(langSet, function(na, langKey){                                 
-                       js_log('load language key: ' + langKey);                        
-                       //do a manual call to the script-lodaer:
-                       js_log('do load: ' + '../../../mwScriptLoader.php?class=$mw.testLang&urid='+ scriptLoaderURID +'&uselang='+langKey );
-                       $j.getScript('../../../mwScriptLoader.php?class=$mw.testLang&urid='+ scriptLoaderURID +'&uselang='+langKey, function(){
+               
+                                       
+               //do a manual call to the script-lodaer:
+               function doProcLangKey(langKey){                        
+                       $j.getScript('../../../mwScriptLoader.php?class=$mw.testLang&urid='+ scriptLoaderURID +'&uselang='+langKey, function(){                 
                                var o='';
                                o+='<tr><td colspan="6" height="20" style="font-size:large"><b>Lang:' + langKey + '</b></td></tr>';             
                                //now for each langage msg: 
@@ -236,7 +236,7 @@ js2AddOnloadHook( function(){
                                                                do_api_req({
                                                                        'data': {
                                                                                'action' : 'parse',
-                                                                               'uselang' : 'fr',
+                                                                               'uselang' : langKey,
                                                                                'text' : '{{int:' + mKey + '|' + msgparam + '}}'
                                                                        },
                                                                        'url' : '../../../api.php'                                      
@@ -266,6 +266,10 @@ js2AddOnloadHook( function(){
                                                                                        var failHtlm = (failTest == 0)?failTest: '<span style="color:red">'+ failTest+'</span>';
                                                                                        $j('#score_card').html( 
                                                                                                'Passed: <span style="color:green">' + passTest + '</span> Failed:' + failHtlm );
+                                                                                               
+                                                                                       //done with this lang... call outer function if we have lang keys left to proccess:
+                                                                                       if(langSet.length!=0)
+                                                                                               doProcLangKey( langSet.pop() );         
                                                                                }                       
                                                                        }else{
                                                                                $t.html(' error ');
@@ -281,9 +285,10 @@ js2AddOnloadHook( function(){
                                        o+='<tr><td colspan="6" height="20"> </td></tr>';                       
                                });
                                //put the output into the page: 
-                               $j('#table_out').append( o );
-                       });
-               });// each lang key
+                               $j('#table_out').append( o );                                                           
+                       });                     
+               }//procc lang key:
+               doProcLangKey( langSet.pop() );
        }
        //by default run the "debug" set:
        doLangTable( langKeyDebug );