From 620a6f6404aa59cf66c6a4f435de4683d0906d88 Mon Sep 17 00:00:00 2001 From: Michael Dale Date: Tue, 3 Nov 2009 06:26:20 +0000 Subject: [PATCH] more language updates --- js2/mwEmbed/mv_embed.js | 31 +++++++++++++++++++------------ js2/mwEmbed/tests/README | 2 ++ js2/mwEmbed/tests/testLang.html | 19 ++++++++++++++----- js2/remoteMwEmbed.js | 1 - 4 files changed, 35 insertions(+), 18 deletions(-) create mode 100644 js2/mwEmbed/tests/README diff --git a/js2/mwEmbed/mv_embed.js b/js2/mwEmbed/mv_embed.js index 7bf7d4cecf..a153a0213a 100644 --- a/js2/mwEmbed/mv_embed.js +++ b/js2/mwEmbed/mv_embed.js @@ -294,14 +294,15 @@ if( !mv_embed_path ) { //a quick check to see if we need to send the msg via the 'parser' //(we can add more detailed check once we support more wiki syntax) - if(ms.indexOf('{{') === -1 && ms.indexOf('[') === -1){ + if( ms.indexOf('{{') === -1 && ms.indexOf('[') === -1){ return ms; } //make sure we have the lagMagic setup: + //@@todo move to init $.lang.magicSetup(); //send the msg key through the parser - pObj = $.parser.pNew( ms ); + var pObj = $.parser.pNew( ms ); //return the transformed msg return pObj.getHTML(); } @@ -598,10 +599,12 @@ if( !mv_embed_path ) { */ // ~ probably a better algorithm out there / should mirror php parser flow ~ + // (we are already running white-space issues ie php parse strips whitespace diffrently) + // ... 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){ - var node = {}; + var node = {}; //inspect each char for(var a=0; a < txt.length; a++){ if( txt[a] == '{' && txt[a+1] == '{' ){ @@ -630,7 +633,7 @@ if( !mv_embed_path ) { /** * parse template text as template name and named params */ - function parseTmplTxt( ts ){ + function parseTmplTxt( ts ){ var tObj = {}; //Get template name: tname = ts.split('\|').shift() ; @@ -645,14 +648,18 @@ 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); + pSet.splice(0,1); if( pSet.length ){ tObj.param = new Array(); - for(var pInx in pSet){ + for(var pInx in pSet){ var tStr = pSet[ pInx ]; + //check for empty param + if(tStr==''){ + tObj.param[ pInx ] = ''; + continue; + } for(var b=0 ; b < tStr.length ; b++){ if(tStr[b] == '=' && b>0 && b