Correct for in loops on arrays.

Reported in bug 29106. Patch by Michael M.
This commit is contained in:
Derk-Jan Hartman 2011-07-02 09:09:05 +00:00
parent c1edd49986
commit 3cae03cef5
Notes: Derk-Jan Hartman 2011-07-02 09:09:05 +00:00
2 changed files with 16 additions and 15 deletions

View file

@ -230,8 +230,8 @@ $(document).ready( function() {
tests++; tests++;
} }
if ( window.console !== undefined ) { if ( window.console !== undefined ) {
for ( message in messages ) { for ( var i = 0; i < messages.length; i++ ) {
console.log( messages[message] ); console.log( messages[i] );
} }
} }
$(this) $(this)

View file

@ -9,7 +9,7 @@
api : { api : {
addToToolbar : function( context, data ) { addToToolbar : function( context, data ) {
var smooth = true, type; var smooth = true, type, i;
for ( type in data ) { for ( type in data ) {
switch ( type ) { switch ( type ) {
@ -93,9 +93,9 @@ api : {
var $table = context.modules.toolbar.$toolbar.find( var $table = context.modules.toolbar.$toolbar.find(
'div[rel=' + data.section + '].section ' + 'div[rel=' + data.page + '].page table' 'div[rel=' + data.section + '].section ' + 'div[rel=' + data.page + '].page table'
); );
for ( var row in data[type] ) { for ( i = 0; i < data.rows.length; i++ ) {
// Row // Row
$table.append( $.wikiEditor.modules.toolbar.fn.buildRow( context, data[type][row] ) ); $table.append( $.wikiEditor.modules.toolbar.fn.buildRow( context, data.rows[i] ) );
} }
smooth = false; smooth = false;
break; break;
@ -107,11 +107,11 @@ api : {
'div[rel=' + data.section + '].section ' + 'div[rel=' + data.page + '].page div' 'div[rel=' + data.section + '].section ' + 'div[rel=' + data.page + '].page div'
); );
var actions = $characters.data( 'actions' ); var actions = $characters.data( 'actions' );
for ( var character in data[type] ) { for ( i = 0; data.character.length; i++ ) {
// Character // Character
$characters $characters
.append( .append(
$( $.wikiEditor.modules.toolbar.fn.buildCharacter( data[type][character], actions ) ) $( $.wikiEditor.modules.toolbar.fn.buildCharacter( data.characters[i], actions ) )
.mousedown( function( e ) { .mousedown( function( e ) {
context.fn.saveCursorAndScrollTop(); context.fn.saveCursorAndScrollTop();
// No dragging! // No dragging!
@ -321,8 +321,8 @@ fn: {
}, },
buildTool : function( context, id, tool ) { buildTool : function( context, id, tool ) {
if ( 'filters' in tool ) { if ( 'filters' in tool ) {
for ( var filter in tool.filters ) { for ( var i = 0; i < tool.filters.length; i++ ) {
if ( $( tool.filters[filter] ).size() === 0 ) { if ( $( tool.filters[i] ).size() === 0 ) {
return null; return null;
} }
} }
@ -470,6 +470,7 @@ fn: {
} ); } );
}, },
buildPage : function( context, id, page ) { buildPage : function( context, id, page ) {
var html;
var $page = $( '<div/>' ).attr( { var $page = $( '<div/>' ).attr( {
'class' : 'page page-' + id, 'class' : 'page page-' + id,
'rel' : id 'rel' : id
@ -477,14 +478,14 @@ fn: {
switch ( page.layout ) { switch ( page.layout ) {
case 'table': case 'table':
$page.addClass( 'page-table' ); $page.addClass( 'page-table' );
var html = html =
'<table cellpadding=0 cellspacing=0 ' + 'border=0 width="100%" class="table table-' + id + '">'; '<table cellpadding=0 cellspacing=0 ' + 'border=0 width="100%" class="table table-' + id + '">';
if ( 'headings' in page ) { if ( 'headings' in page ) {
html += $.wikiEditor.modules.toolbar.fn.buildHeading( context, page.headings ); html += $.wikiEditor.modules.toolbar.fn.buildHeading( context, page.headings );
} }
if ( 'rows' in page ) { if ( 'rows' in page ) {
for ( var row in page.rows ) { for ( var i = 0; i < page.rows.length; i++ ) {
html += $.wikiEditor.modules.toolbar.fn.buildRow( context, page.rows[row] ); html += $.wikiEditor.modules.toolbar.fn.buildRow( context, page.rows[i] );
} }
} }
$page.html( html ); $page.html( html );
@ -500,7 +501,7 @@ fn: {
$characters.attr( 'dir', page.direction ); $characters.attr( 'dir', page.direction );
} }
if ( 'characters' in page ) { if ( 'characters' in page ) {
var html = ''; html = '';
for ( var i = 0; i < page.characters.length; i++ ) { for ( var i = 0; i < page.characters.length; i++ ) {
html += $.wikiEditor.modules.toolbar.fn.buildCharacter( page.characters[i], actions ); html += $.wikiEditor.modules.toolbar.fn.buildCharacter( page.characters[i], actions );
} }
@ -530,8 +531,8 @@ fn: {
}, },
buildHeading : function( context, headings ) { buildHeading : function( context, headings ) {
var html = '<tr>'; var html = '<tr>';
for ( var heading in headings ) { for ( var i = 0; i< headings.length; i++ ) {
html += '<th>' + $.wikiEditor.autoMsg( headings[heading], ['html', 'text'] ) + '</th>'; html += '<th>' + $.wikiEditor.autoMsg( headings[i], ['html', 'text'] ) + '</th>';
} }
return html; return html;
}, },