r92651 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92650‎ | r92651 | r92652 >
Date:18:10, 20 July 2011
Author:inez
Status:deferred
Tags:
Comment:
New implementation of getLines method that works
Modified paths:
  • /trunk/parsers/wikidom/lib/es/es.Content.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.Content.js
@@ -560,15 +560,16 @@
561561 };
562562
563563 Content.prototype.getLines = function() {
564 - var lines = [],
565 - line = null,
566 - offset = 0,
567 - left = '',
568 - right = '',
569 - leftPlain,
570 - rightPlain,
571 - j,k,i;
572 -
 564+ var lines = [];
 565+ var right = '';
 566+ var left = '';
 567+ var rightPlain;
 568+ var leftPlain;
 569+ var i;
 570+ var j;
 571+ var line;
 572+ var offset = 0;
 573+
573574 for ( i = 0; i < this.data.length; i++ ) {
574575
575576 if ( line == null ) {
@@ -577,23 +578,24 @@
578579 annotations : []
579580 };
580581 }
581 -
 582+
582583 right = this.data[i];
583584 leftPlain = typeof left === 'string';
584585 rightPlain = typeof right === 'string';
585 -
 586+
586587 if ( rightPlain && right == "\n" ) {
587588 lines.push(line);
588589 line = null;
589590 offset = i + 1;
 591+ left = '';
590592 continue;
591593 }
592594
593 - for ( j = 1; j < left.length; j++ ) {
594 - if ( rightPlain || this.indexOfAnnotation( i, left[j], true ) === -1 ) {
 595+ if ( !leftPlain ) {
 596+ for ( j = 1; j < left.length; j++ ) {
595597 for ( k = line.annotations.length - 1; k >= 0; k-- ) {
596 - if ( line.annotations[k].type === left[j].type ) {
597 - if ( Content.compareObjects( line.annotations[k].data, left[j].data ) ) {
 598+ if ( left[j].type === line.annotations[k].type ) {
 599+ if ( Content.compareObjects( left[j].data, line.annotations[k].data ) ) {
598600 line.annotations[k].range.end = i - offset;
599601 break;
600602 }
@@ -602,26 +604,24 @@
603605 }
604606 }
605607
606 - for ( j = 1; j < right.length; j++ ) {
607 - if ( leftPlain || this.indexOfAnnotation( i - 1, right[j], true ) === -1 ) {
608 - var annotation = Content.copyObject( right[j] );
609 - annotation.range = {
610 - start : i - offset,
611 - end : i + 1 - offset
612 - };
613 - line.annotations.push( annotation );
 608+ if ( !rightPlain ) {
 609+ for ( j = 1; j < right.length; j++ ) {
 610+ if ( leftPlain || this.indexOfAnnotation( i - 1, right[j], true ) === -1 ) {
 611+ var annotation = Content.copyObject( right[j] );
 612+ annotation.range = {
 613+ start : i - offset,
 614+ end : i + 1 - offset
 615+ };
 616+ line.annotations.push( annotation );
 617+ }
614618 }
615619 }
 620+
 621+ line.text += rightPlain ? right : right[0];
616622
617 - if ( rightPlain ) {
618 - line.text += right;
619 - } else {
620 - line.text += right[0];
621 - }
622 -
623623 left = right;
624624 }
625 -
 625+
626626 if ( line != null ) {
627627 lines.push(line);
628628 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r92653MFT r77974 through r92651awjrichards18:14, 20 July 2011

Status & tagging log