r91324 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91323‎ | r91324 | r91325 >
Date:23:16, 1 July 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Fixed same-line deletion, still issues with inter-line deleteion.
Modified paths:
  • /trunk/parsers/wikidom/lib/es/es.ParagraphBlock.js (modified) (history)
  • /trunk/parsers/wikidom/lib/es/es.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/es/es.ParagraphBlock.js
@@ -47,46 +47,47 @@
4848 /**
4949 * Deletes content in a block within a range.
5050 *
51 - * @param offset {Integer} Position to start removing content from
52 - * @param length {Integer} Length of content to remove
 51+ * @param offset {Integer} Offset to start removing content from
 52+ * @param length {Integer} Offset to start removing content to
5353 */
54 -ParagraphBlock.prototype.deleteContent = function( offset, length ) {
55 - var start,
56 - end,
 54+ParagraphBlock.prototype.deleteContent = function( start, end ) {
 55+ // Normalize start/end
 56+ if ( end < start ) {
 57+ var tmp = end;
 58+ end = start;
 59+ start = tmp;
 60+ }
 61+ var line,
 62+ length,
5763 from,
58 - to,
59 - line,
60 - lineOffset;
61 - for ( var i = 0; i < this.lines.length; i++ ) {
 64+ to;
 65+ for ( var i = 0; i < this.lines.length || !(from && to); i++ ) {
6266 line = this.lines[i];
63 - start = offset - lineOffset;
64 - end = start + length;
65 - if ( start >= 0 && start < line.text.length) {
 67+ length = line.text.length;
 68+ if ( !from && start < length) {
6669 from = {
6770 'line': line,
6871 'index': i,
6972 'offset': start
7073 };
7174 }
72 - if ( end >= 0 && end < line.text.length) {
 75+ if ( !to && end < length) {
7376 to = {
7477 'line': line,
7578 'index': i,
7679 'offset': end
7780 };
7881 }
79 - lineOffset += line.text.length;
 82+ start -= length;
 83+ end -= length;
8084 }
81 - if ( !( from && to ) ) {
82 - throw 'FAIL';
83 - }
8485 if ( from.index === to.index ) {
85 - from.line.text = from.line.text.substring( 0, from.line.offset )
86 - + from.line.text.substring( to.line.offset );
 86+ from.line.text = from.line.text.substring( 0, from.offset )
 87+ + from.line.text.substring( to.offset );
8788 } else {
8889 // Replace "from" line with remaining content of "from" and "to" lines
89 - from.line.text = from.line.text.substring( 0, from.line.offset )
90 - + to.line.text.substring( to.line.offset );
 90+ from.line.text = from.line.text.substring( 0, from.offset )
 91+ + to.line.text.substring( to.offset );
9192 // Remove lines after "from" up to and including "to"
9293 this.lines = this.lines.splice( from.index + 1, to.index - from.index );
9394 }
Index: trunk/parsers/wikidom/lib/es/es.js
@@ -95,3 +95,21 @@
9696 }
9797 return through;
9898 };
 99+
 100+function Content( data ) {
 101+ this.setData( data );
 102+}
 103+
 104+Content.prototype.setData = function( data ) {
 105+ // Data type detection
 106+ if ( typeof data === 'string' ) {
 107+ this.type = 'string';
 108+ } else if ( $.isArray( data ) ) {
 109+
 110+ } else if ( $.isPlainObject( data ) ) {
 111+ if ( 'type' in data && '' ) {
 112+
 113+ }
 114+ }
 115+ this.data = data;
 116+};

Status & tagging log