r95293 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95292‎ | r95293 | r95294 >
Date:01:13, 23 August 2011
Author:inez
Status:deferred
Tags:
Comment:
Almost completly ready getWikiDom for ListBlock
Modified paths:
  • /trunk/parsers/wikidom/lib/es/es.ListBlock.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.ListBlock.js
@@ -358,10 +358,29 @@
359359 es.ListBlock.prototype.getWikiDom = function() {
360360 var items = this.list.items;
361361 var stack = [];
 362+ var lastStyle = null;
362363
363364 for ( var i = 0; i < items.length; i++ ) {
364365 var item = items[i];
365366 var itemLevel = item.getLevel();
 367+
 368+ if ( itemLevel + 1 === stack.length ) {
 369+ if ( lastStyle !== null && lastStyle != item.getStyle() ) {
 370+ if ( stack[stack.length - 2].items.length === 0 ) {
 371+ stack[stack.length - 2].items.push( {
 372+ 'lists' : []
 373+ } );
 374+ } else if( !stack[stack.length - 2].items[stack[stack.length - 2].items.length - 1].lists ) {
 375+ stack[stack.length - 2].items[stack[stack.length - 2].items.length - 1].lists = [];
 376+ }
 377+ stack[stack.length - 2].items[stack[stack.length - 2].items.length - 1].lists.push( stack.pop() );
 378+ stack.push( {
 379+ 'style' : item.getStyle(),
 380+ 'items' : []
 381+ } );
 382+ lastStyle = item.getStyle();
 383+ }
 384+ }
366385
367386 if ( itemLevel + 1 > stack.length ) {
368387 for( var j = stack.length; j < itemLevel + 1; j++ ) {
@@ -389,6 +408,7 @@
390409 stack[stack.length - 1].items.push( {
391410 'line' : item.content.getWikiDomLines()[0] }
392411 );
 412+ lastStyle = item.getStyle();
393413 }
394414 }
395415

Status & tagging log