Index: trunk/parsers/wikidom/lib/es/es.Document.js |
— | — | @@ -5,7 +5,8 @@ |
6 | 6 | */ |
7 | 7 | function Document( blocks ) { |
8 | 8 | this.blocks = []; |
9 | | - for( var i = 0; i < blocks.length; i++ ) { |
| 9 | + var i; |
| 10 | + for( i = 0; i < blocks.length; i++ ) { |
10 | 11 | this.appendBlock(blocks[i]); |
11 | 12 | } |
12 | 13 | this.width = null; |
— | — | @@ -77,7 +78,7 @@ |
78 | 79 | } else { |
79 | 80 | this.blocks.push( block ); |
80 | 81 | } |
81 | | -} |
| 82 | +}; |
82 | 83 | |
83 | 84 | /** |
84 | 85 | * Removes a block from the document. |
— | — | @@ -93,7 +94,8 @@ |
94 | 95 | // Remember width, to avoid updates when without width changes |
95 | 96 | this.width = this.$.innerWidth(); |
96 | 97 | // Render blocks |
97 | | - for ( var i = 0; i < this.blocks.length; i++ ) { |
| 98 | + var i; |
| 99 | + for ( i = 0; i < this.blocks.length; i++ ) { |
98 | 100 | this.$.append( this.blocks[i].$ ); |
99 | 101 | this.blocks[i].renderContent( offset, callback ); |
100 | 102 | } |
Index: trunk/parsers/wikidom/lib/es/es.js |
— | — | @@ -21,6 +21,8 @@ |
22 | 22 | */ |
23 | 23 | function extend( dst, src ) { |
24 | 24 | var base = new src(); |
| 25 | + var i; // iterator |
| 26 | + |
25 | 27 | for ( i in base ) { |
26 | 28 | if ( typeof base[i] === 'function' && !( i in dst.prototype ) ) { |
27 | 29 | dst.prototype[i] = base[i]; |
— | — | @@ -94,7 +96,7 @@ |
95 | 97 | Selection.prototype.through = function() { |
96 | 98 | var through = []; |
97 | 99 | if ( this.from !== this.to && this.from.nextBlock() !== this.to ) { |
98 | | - var next = this.from.nextBlock() |
| 100 | + var next = this.from.nextBlock(); |
99 | 101 | while ( next && next !== this.to ) { |
100 | 102 | through.push( next ); |
101 | 103 | next = next.nextBlock(); |
— | — | @@ -112,10 +114,10 @@ |
113 | 115 | if ( typeof data === 'string' ) { |
114 | 116 | this.type = 'string'; |
115 | 117 | } else if ( $.isArray( data ) ) { |
116 | | - |
| 118 | + // TODO |
117 | 119 | } else if ( $.isPlainObject( data ) ) { |
118 | 120 | if ( 'type' in data && '' ) { |
119 | | - |
| 121 | + // TODO |
120 | 122 | } |
121 | 123 | } |
122 | 124 | this.data = data; |
Index: trunk/parsers/wikidom/lib/es/es.Surface.js |
— | — | @@ -89,8 +89,8 @@ |
90 | 90 | $block = $(this); |
91 | 91 | } ); |
92 | 92 | } |
93 | | - var block = $block.data( 'block' ) |
94 | | - blockPosition = $block.offset() |
| 93 | + var block = $block.data( 'block' ), |
| 94 | + blockPosition = $block.offset(), |
95 | 95 | mousePosition = new Position( e.pageX - blockPosition.left, e.pageY - blockPosition.top ); |
96 | 96 | return new Location( block, block.getOffset( mousePosition ) ); |
97 | 97 | }; |
— | — | @@ -176,7 +176,7 @@ |
177 | 177 | break; |
178 | 178 | } |
179 | 179 | return true; |
180 | | -} |
| 180 | +}; |
181 | 181 | |
182 | 182 | Surface.prototype.onKeyUp = function( e ) { |
183 | 183 | switch ( e.keyCode ) { |
— | — | @@ -197,7 +197,7 @@ |
198 | 198 | break; |
199 | 199 | } |
200 | 200 | return true; |
201 | | -} |
| 201 | +}; |
202 | 202 | |
203 | 203 | Surface.prototype.handleBackspace = function() { |
204 | 204 | var block = this.location.block, |
— | — | @@ -211,7 +211,7 @@ |
212 | 212 | this.selection = new Selection(); |
213 | 213 | this.drawSelection(); |
214 | 214 | this.location = new Location( block, offset ); |
215 | | -} |
| 215 | +}; |
216 | 216 | |
217 | 217 | Surface.prototype.handleDelete = function() { |
218 | 218 | var block = this.location.block, |
— | — | @@ -265,6 +265,8 @@ |
266 | 266 | * Displays current selection behind document content. |
267 | 267 | */ |
268 | 268 | Surface.prototype.drawSelection = function() { |
| 269 | + var blockWidth; |
| 270 | + |
269 | 271 | if ( this.selection.from && this.selection.to ) { |
270 | 272 | this.selection.normalize(); |
271 | 273 | var from = { |
— | — | @@ -297,7 +299,7 @@ |
298 | 300 | this.$rangeEnd.hide(); |
299 | 301 | } else { |
300 | 302 | // Multiple line selection |
301 | | - var blockWidth = block.$.width(); |
| 303 | + blockWidth = block.$.width(); |
302 | 304 | this.$rangeStart |
303 | 305 | .css( { |
304 | 306 | 'top': blockOffset.top + from.position.top, |
— | — | @@ -329,11 +331,11 @@ |
330 | 332 | } |
331 | 333 | } else { |
332 | 334 | // Multiple block selection |
333 | | - var blockWidth = Math.max( |
| 335 | + blockWidth = Math.max( |
334 | 336 | from.location.block.$.width(), |
335 | 337 | to.location.block.$.width() |
336 | | - ) |
337 | | - fromBlockOffset = from.location.block.$.offset(), |
| 338 | + ); |
| 339 | + var fromBlockOffset = from.location.block.$.offset(), |
338 | 340 | toBlockOffset = to.location.block.$.offset(), |
339 | 341 | blockLeft = Math.min( fromBlockOffset.left, toBlockOffset.left ); |
340 | 342 | this.$rangeStart |
— | — | @@ -526,6 +528,9 @@ |
527 | 529 | * @param selection {Selection} Range to apply annotation to |
528 | 530 | */ |
529 | 531 | Surface.prototype.annotateContent= function( method, annotation, selection ) { |
| 532 | + var block; |
| 533 | + var i; |
| 534 | + |
530 | 535 | if ( selection === undefined ) { |
531 | 536 | selection = this.selection; |
532 | 537 | } |
— | — | @@ -542,8 +547,8 @@ |
543 | 548 | } ); |
544 | 549 | } else { |
545 | 550 | // Multiple block annotation |
546 | | - for ( var i = from.block.getIndex(), end = to.block.getIndex(); i <= end; i++ ) { |
547 | | - var block = this.doc.blocks[i]; |
| 551 | + for ( i = from.block.getIndex(), end = to.block.getIndex(); i <= end; i++ ) { |
| 552 | + block = this.doc.blocks[i]; |
548 | 553 | if ( block === from.block ) { |
549 | 554 | // From offset to length |
550 | 555 | block.annotateContent( method, annotation, from.offset, block.getLength() ); |
Index: trunk/parsers/wikidom/lib/es/es.Content.js |
— | — | @@ -83,7 +83,8 @@ |
84 | 84 | */ |
85 | 85 | Content.compareObjects = function( a, b, asymmetrical ) { |
86 | 86 | var aValue, bValue, aType, bType; |
87 | | - for ( var k in a ) { |
| 87 | + var k; |
| 88 | + for ( k in a ) { |
88 | 89 | aValue = a[k]; |
89 | 90 | bValue = b[k]; |
90 | 91 | aType = typeof aValue; |
— | — | @@ -91,7 +92,7 @@ |
92 | 93 | if ( aType !== bType |
93 | 94 | || ( ( aType === 'string' || aType === 'number' ) && aValue !== bValue ) |
94 | 95 | || ( $.isPlainObject( aValue ) && !Content.compareObjects( aValue, bValue ) ) ) { |
95 | | - return false |
| 96 | + return false; |
96 | 97 | } |
97 | 98 | } |
98 | 99 | // If the check is not asymmetrical, recursing with the arguments swapped will verify our result |
— | — | @@ -106,7 +107,8 @@ |
107 | 108 | */ |
108 | 109 | Content.copyObject = function( source ) { |
109 | 110 | var destination = {}; |
110 | | - for ( var key in source ) { |
| 111 | + var key; |
| 112 | + for ( key in source ) { |
111 | 113 | sourceValue = source[key]; |
112 | 114 | sourceType = typeof sourceValue; |
113 | 115 | if ( sourceType === 'string' || sourceType === 'number' ) { |
— | — | @@ -129,7 +131,8 @@ |
130 | 132 | Content.convertLine = function( line ) { |
131 | 133 | // Convert string to array of characters |
132 | 134 | var data = line.text.split(''); |
133 | | - for ( var i in line.annotations ) { |
| 135 | + var i; |
| 136 | + for ( i in line.annotations ) { |
134 | 137 | var src = line.annotations[i]; |
135 | 138 | // Build simplified annotation object |
136 | 139 | var dst = { 'type': src.type }; |
— | — | @@ -137,7 +140,8 @@ |
138 | 141 | dst.data = Content.copyObject( src.data ); |
139 | 142 | } |
140 | 143 | // Apply annotation to range |
141 | | - for ( var k = src.range.start; k < src.range.end; k++ ) { |
| 144 | + var k; |
| 145 | + for ( k = src.range.start; k < src.range.end; k++ ) { |
142 | 146 | // Auto-convert to array |
143 | 147 | typeof data[k] === 'string' && ( data[k] = [data[k]] ); |
144 | 148 | // Append |
— | — | @@ -170,7 +174,8 @@ |
171 | 175 | */ |
172 | 176 | Content.newFromLines = function( lines ) { |
173 | 177 | var data = []; |
174 | | - for ( var i = 0; i < lines.length; i++ ) { |
| 178 | + var i; |
| 179 | + for ( i = 0; i < lines.length; i++ ) { |
175 | 180 | data = data.concat( Content.convertLine( lines[i] ) ); |
176 | 181 | if ( i < lines.length - 1 ) { |
177 | 182 | data.push( '\n' ); |
— | — | @@ -217,7 +222,8 @@ |
218 | 223 | throw 'Invalid stack error. An element is missing from the stack.'; |
219 | 224 | } |
220 | 225 | // Close each already opened annotation |
221 | | - for ( var i = stack.length - 1; i >= depth + 1; i-- ) { |
| 226 | + var i; |
| 227 | + for ( i = stack.length - 1; i >= depth + 1; i-- ) { |
222 | 228 | out += typeof renderers[stack[i].type]['close'] === 'function' |
223 | 229 | ? renderers[stack[i].type]['close']( stack[i].data ) |
224 | 230 | : renderers[stack[i].type]['close']; |
— | — | @@ -227,7 +233,8 @@ |
228 | 234 | ? renderers[type]['close']( annotation.data ) |
229 | 235 | : renderers[type]['close']; |
230 | 236 | // Re-open each previously opened annotation |
231 | | - for ( var i = depth + 1; i < stack.length; i++ ) { |
| 237 | + var i; |
| 238 | + for ( i = depth + 1; i < stack.length; i++ ) { |
232 | 239 | out += typeof renderers[stack[i].type]['open'] === 'function' |
233 | 240 | ? renderers[stack[i].type]['open']( stack[i].data ) |
234 | 241 | : renderers[stack[i].type]['open']; |
— | — | @@ -257,11 +264,12 @@ |
258 | 265 | if ( end === undefined ) { |
259 | 266 | end = this.data.length; |
260 | 267 | } else { |
261 | | - end = Math.min( this.data.length, end ) |
| 268 | + end = Math.min( this.data.length, end ); |
262 | 269 | } |
263 | 270 | // Copy characters |
264 | 271 | var text = ''; |
265 | | - for ( var i = start; i < end; i++ ) { |
| 272 | + var i; |
| 273 | + for ( i = start; i < end; i++ ) { |
266 | 274 | // If not using in IE6 or IE7 (which do not support array access for strings) use this.. |
267 | 275 | // text += this.data[i][0]; |
268 | 276 | // Otherwise use this... |
— | — | @@ -296,14 +304,15 @@ |
297 | 305 | var neighbor = this.data[Math.max( start - 1, 0 )]; |
298 | 306 | if ( $.isArray( neighbor ) ) { |
299 | 307 | var annotations = neighbor.slice( 1 ); |
300 | | - for ( var i = 0; i < insert.length; i++ ) { |
| 308 | + var i; |
| 309 | + for ( i = 0; i < insert.length; i++ ) { |
301 | 310 | if ( typeof insert[i] === 'string' ) { |
302 | 311 | insert[i] = [insert[i]]; |
303 | 312 | } |
304 | 313 | insert[i] = insert[i].concat( annotations ); |
305 | 314 | } |
306 | 315 | } |
307 | | - Array.prototype.splice.apply( this.data, [start, 0].concat( insert ) ) |
| 316 | + Array.prototype.splice.apply( this.data, [start, 0].concat( insert ) ); |
308 | 317 | }; |
309 | 318 | |
310 | 319 | /** |
— | — | @@ -339,8 +348,9 @@ |
340 | 349 | */ |
341 | 350 | Content.prototype.coverageOfAnnotation = function( start, end, annotation, strict ) { |
342 | 351 | var coverage = []; |
343 | | - for ( var i = start; i < end; i++ ) { |
344 | | - var index = this.indexOfAnnotation( i, annotation ); |
| 352 | + var i, index; |
| 353 | + for ( i = start; i < end; i++ ) { |
| 354 | + index = this.indexOfAnnotation( i, annotation ); |
345 | 355 | if ( typeof this.data[i] !== 'string' && index !== -1 ) { |
346 | 356 | if ( strict ) { |
347 | 357 | if ( Content.compareObjects( this.data[i][index].data, annotation.data ) ) { |
— | — | @@ -367,8 +377,9 @@ |
368 | 378 | */ |
369 | 379 | Content.prototype.indexOfAnnotation = function( offset, annotation, strict ) { |
370 | 380 | var annotatedCharacter = this.data[offset]; |
| 381 | + var i; |
371 | 382 | if ( typeof annotatedCharacter !== 'string' ) { |
372 | | - for ( var i = 1; i < this.data[offset].length; i++ ) { |
| 383 | + for ( i = 1; i < this.data[offset].length; i++ ) { |
373 | 384 | if ( annotatedCharacter[i].type === annotation.type ) { |
374 | 385 | if ( strict ) { |
375 | 386 | if ( Content.compareObjects( annotatedCharacter[i].data, annotation.data ) ) { |
— | — | @@ -398,6 +409,8 @@ |
399 | 410 | * @param end {Integer} Offset to stop annotating to |
400 | 411 | */ |
401 | 412 | Content.prototype.annotate = function( method, annotation, start, end ) { |
| 413 | + var i; |
| 414 | + |
402 | 415 | start = Math.max( start, 0 ); |
403 | 416 | end = Math.min( end, this.data.length ); |
404 | 417 | if ( method === 'toggle' ) { |
— | — | @@ -411,7 +424,7 @@ |
412 | 425 | } |
413 | 426 | if ( method === 'add' ) { |
414 | 427 | var duplicate; |
415 | | - for ( var i = start; i < end; i++ ) { |
| 428 | + for ( i = start; i < end; i++ ) { |
416 | 429 | duplicate = -1; |
417 | 430 | if ( typeof this.data[i] === 'string' ) { |
418 | 431 | // Never annotate new lines |
— | — | @@ -433,7 +446,7 @@ |
434 | 447 | } |
435 | 448 | } |
436 | 449 | } else if ( method === 'remove' ) { |
437 | | - for ( var i = start; i < end; i++ ) { |
| 450 | + for ( i = start; i < end; i++ ) { |
438 | 451 | if ( typeof this.data[i] !== 'string' ) { |
439 | 452 | if ( annotation.type === 'all' ) { |
440 | 453 | // Remove all annotations by converting the annotated character to a plain |
— | — | @@ -466,29 +479,30 @@ |
467 | 480 | right, |
468 | 481 | leftPlain, |
469 | 482 | rightPlain, |
| 483 | + i, j, // iterators |
470 | 484 | stack = []; |
471 | | - for ( var i = 0; i < this.data.length; i++ ) { |
| 485 | + for ( i = 0; i < this.data.length; i++ ) { |
472 | 486 | right = this.data[i]; |
473 | 487 | leftPlain = typeof left === 'string'; |
474 | 488 | rightPlain = typeof right === 'string'; |
475 | 489 | if ( !leftPlain && rightPlain ) { |
476 | 490 | // [formatted][plain] pair, close any annotations for left |
477 | | - for ( var j = 1; j < left.length; j++ ) { |
| 491 | + for ( j = 1; j < left.length; j++ ) { |
478 | 492 | out += Content.renderAnnotation( 'close', left[j], stack ); |
479 | 493 | } |
480 | 494 | } else if ( leftPlain && !rightPlain ) { |
481 | 495 | // [plain][formatted] pair, open any annotations for right |
482 | | - for ( var j = 1; j < right.length; j++ ) { |
| 496 | + for ( j = 1; j < right.length; j++ ) { |
483 | 497 | out += Content.renderAnnotation( 'open', right[j], stack ); |
484 | 498 | } |
485 | 499 | } else if ( !leftPlain && !rightPlain ) { |
486 | 500 | // [formatted][formatted] pair, open/close any differences |
487 | | - for ( var j = 1; j < left.length; j++ ) { |
| 501 | + for ( j = 1; j < left.length; j++ ) { |
488 | 502 | if ( right.indexOf( left[j] ) === -1 ) { |
489 | 503 | out += Content.renderAnnotation( 'close', left[j], stack ); |
490 | 504 | } |
491 | 505 | } |
492 | | - for ( var j = 1; j < right.length; j++ ) { |
| 506 | + for ( j = 1; j < right.length; j++ ) { |
493 | 507 | if ( left.indexOf( right[j] ) === -1 ) { |
494 | 508 | out += Content.renderAnnotation( 'open', right[j], stack ); |
495 | 509 | } |
— | — | @@ -498,4 +512,4 @@ |
499 | 513 | left = right; |
500 | 514 | } |
501 | 515 | return out; |
502 | | -} |
| 516 | +}; |
Index: trunk/parsers/wikidom/lib/es/es.TextFlow.js |
— | — | @@ -56,7 +56,7 @@ |
57 | 57 | var virtual = line < this.lines.length - 1 |
58 | 58 | && this.boundaryTest.exec( this.lines[line].text.substr( -1 ) ) ? -1 : 0; |
59 | 59 | line = Math.min( line, this.lines.length - 1 ); |
60 | | - var $ruler = $( '<div class="editSurface-ruler"></div>' ).appendTo( this.$ ) |
| 60 | + var $ruler = $( '<div class="editSurface-ruler"></div>' ).appendTo( this.$ ), |
61 | 61 | ruler = $ruler[0], |
62 | 62 | fit = this.fitCharacters( |
63 | 63 | this.lines[line].start, this.lines[line].end, ruler, position.left |
— | — | @@ -112,8 +112,8 @@ |
113 | 113 | } |
114 | 114 | position.top += this.lines[line].height; |
115 | 115 | line++; |
116 | | - }; |
117 | | - |
| 116 | + } |
| 117 | + |
118 | 118 | /* |
119 | 119 | * Virtual n+1 position |
120 | 120 | * |
— | — | @@ -271,7 +271,7 @@ |
272 | 272 | * container and measure it. |
273 | 273 | */ |
274 | 274 | rs.$ruler = $( '<div> </div>' ).appendTo( this.$ ); |
275 | | - rs.width = rs.$ruler.innerWidth() |
| 275 | + rs.width = rs.$ruler.innerWidth(); |
276 | 276 | |
277 | 277 | // TODO: Take offset into account |
278 | 278 | // Ignore offset optimization if the width has changed or the text has never been flowed before |
Index: trunk/parsers/wikidom/lib/es/es.Cursor.js |
— | — | @@ -45,5 +45,5 @@ |
46 | 46 | if( this.cursorInterval ) { |
47 | 47 | clearInterval( this.cursorInterval ); |
48 | 48 | } |
49 | | - this.$.hide() |
| 49 | + this.$.hide(); |
50 | 50 | }; |
Index: trunk/parsers/wikidom/lib/wiki.util.js |
— | — | @@ -4,12 +4,13 @@ |
5 | 5 | wiki.util = { |
6 | 6 | 'str': { |
7 | 7 | 'repeat': function( pattern, count ) { |
8 | | - if ( count < 1 ) return ''; |
| 8 | + if ( count < 1 ) { return ''; } |
9 | 9 | var result = ''; |
10 | 10 | while ( count > 0 ) { |
11 | | - if ( count & 1 ) result += pattern; |
12 | | - count >>= 1, pattern += pattern; |
13 | | - }; |
| 11 | + if ( count & 1 ) { result += pattern; } |
| 12 | + count >>= 1; |
| 13 | + pattern += pattern; |
| 14 | + } |
14 | 15 | return result; |
15 | 16 | } |
16 | 17 | }, |
— | — | @@ -24,8 +25,9 @@ |
25 | 26 | }, |
26 | 27 | 'attr': function( attributes, prespace ) { |
27 | 28 | var attr = []; |
| 29 | + var name; |
28 | 30 | if ( attributes ) { |
29 | | - for ( var name in attributes ) { |
| 31 | + for ( name in attributes ) { |
30 | 32 | attr.push( name + '="' + attributes[name] + '"' ); |
31 | 33 | } |
32 | 34 | } |
Index: trunk/parsers/wikidom/lib/wiki.AnnotationRenderer.js |
— | — | @@ -60,8 +60,8 @@ |
61 | 61 | * @return String: Wrapped text |
62 | 62 | */ |
63 | 63 | this.apply = function( text ) { |
64 | | - var out = ''; |
65 | | - for ( var i = 0, iMax = text.length; i <= iMax; i++ ) { |
| 64 | + var out = '', i; |
| 65 | + for ( i = 0, iMax = text.length; i <= iMax; i++ ) { |
66 | 66 | if ( i in insertions ) { |
67 | 67 | out += insertions[i].join( '' ); |
68 | 68 | } |