//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();
}
*/
// ~ 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] == '{' ){
/**
* parse template text as template name and named params
*/
- function parseTmplTxt( ts ){
+ function parseTmplTxt( ts ){
var tObj = {};
//Get template name:
tname = ts.split('\|').shift() ;
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<tStr.length && tStr[b-1]!='\\'){
//named param
}
}
}
- }
+ }
return tObj;
}
function getMagicTxtFromTempNode( node ){
//wikiText updates should invalidate pOut
if( this.pOut == ''){
this.parse();
- }
+ }
return this.pOut;
}
};
* Store all the mwEmbed jQuery-specific bindings
* (set up after jQuery is available).
*
- * These functions are generaly are loaders that do the dynamic mapping of
- * dependencies for a given componet
+ * These functions are genneraly are loaders that do the dynamic mapping of
+ * dependencies for a given commponet
*
*
*/
--- /dev/null
+This folder contains stand alone tests of js2/mwEmbed components.
+The tests folder does not need to be included or exposed in a production environment.
\ No newline at end of file
}
</style>
<script type="text/javascript" >
+var scriptLoaderURID = 't10';
//for just setting one or two to test at a time for debug
-var langKeyDebug = ['en'];
+var langKeyDebug = ['fr'];
//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'];
$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=5&lang='+langKey );
- $j.getScript('../../../mwScriptLoader.php?class=$mw.testLang&urid=8&lang='+langKey, function(){
+ js_log('do load: ' + '../../../mwScriptLoader.php?class=$mw.testLang&urid='+ scriptLoaderURID +'&lang='+langKey );
+ $j.getScript('../../../mwScriptLoader.php?class=$mw.testLang&urid='+ scriptLoaderURID +'&lang='+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:
do_api_req({
'data': {
'action' : 'parse',
+ 'uselang' : 'fr',
'text' : '{{int:' + mKey + '|' + msgparam + '}}'
},
'url' : '../../../api.php'
}, function( data ) {
var t = '#'+ tkey ;
if(data.parse && data.parse.text && data.parse.text['*']){
- $j(t).html( data.parse.text['*'] );
+ $j(t).html( data.parse.text['*'] );
+ var js_txt = $j.trim( $j(t + '_js').text().replace('\n', '') );
+ var php_txt = $j.trim( $j(t + ' p').text())
//just get the part in the <p> to compare with js version
- if( $j.trim( $j(t + ' p').html() ) != $j.trim( $j(t + '_js').html() ) ){
+ if( js_txt != php_txt ){
+ var cat = $j.trim( $j(t + ' p').text() );
+ var dog = $j.trim( $j(t + '_js').text() );
+ if( cat == dog)
+ alert('wtf');
+ //debugger;
$j(t).css('color', 'red');
failTest++;
}else{
var urlparts = getRemoteEmbedPath();
var mwEmbedHostPath = urlparts[0];
var reqAguments = urlparts[1];
-
addOnloadHook( function(){
//only do rewrites if MV_EMBED / js2 is "off"
if( typeof MV_EMBED_VERSION == 'undefined' ) {