r91312 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91311‎ | r91312 | r91313 >
Date:22:27, 1 July 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Simplified insertContent
Modified paths:
  • /trunk/parsers/wikidom/lib/es/es.ParagraphBlock.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.ParagraphBlock.js
@@ -31,20 +31,15 @@
3232 */
3333 ParagraphBlock.prototype.insertContent = function( offset, content ) {
3434 var lineOffset = 0;
35 - if ( offset === 0 && this.lines.length ) {
36 - this.lines[0].text = content.toString() + this.lines[0].text;
37 - } else {
38 - for ( var i = 0; i < this.lines.length; i++ ) {
39 - if ( offset >= lineOffset && offset < lineOffset + this.lines[i].text.length ) {
40 - this.lines[i].text = this.lines[i].text.substring( 0, offset - lineOffset )
41 - + content.toString()
42 - + this.lines[i].text.substring( offset - lineOffset )
43 - break;
44 - }
45 - lineOffset += this.lines[i].text.length;
 35+ for ( var i = 0; i < this.lines.length; i++ ) {
 36+ if ( offset >= lineOffset && offset < lineOffset + this.lines[i].text.length ) {
 37+ this.lines[i].text = this.lines[i].text.substring( 0, offset - lineOffset )
 38+ + content.toString()
 39+ + this.lines[i].text.substring( offset - lineOffset )
 40+ break;
4641 }
 42+ lineOffset += this.lines[i].text.length;
4743 }
48 -
4944 this.updateText();
5045 this.flow.render();
5146 };
@@ -82,6 +77,9 @@
8378 }
8479 lineOffset += line.text.length;
8580 }
 81+ if ( !( from && to ) ) {
 82+ throw 'FAIL';
 83+ }
8684 if ( from.index === to.index ) {
8785 from.line.text = from.line.text.substring( 0, from.line.offset )
8886 + from.line.text.substring( to.line.offset );
@@ -93,6 +91,7 @@
9492 this.lines = this.lines.splice( from.index + 1, to.index - from.index );
9593 }
9694 this.updateText();
 95+ this.flow.render();
9796 };
9897
9998 /**

Status & tagging log