Index: trunk/extensions/Configure/Configure.php |
— | — | @@ -147,7 +147,7 @@ |
148 | 148 | /** |
149 | 149 | * Styles versions, you shouldn't change it |
150 | 150 | */ |
151 | | -$wgConfigureStyleVersion = '16'; |
| 151 | +$wgConfigureStyleVersion = '17'; |
152 | 152 | |
153 | 153 | # Adding new rights... |
154 | 154 | $wgAvailableRights[] = 'configure'; |
Index: trunk/extensions/Configure/Configure.js |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | * create JavaScript buttons to allow to modify the form to have more |
5 | 5 | * flexibility |
6 | 6 | */ |
7 | | - |
| 7 | + |
8 | 8 | var allSettings = undefined; |
9 | 9 | |
10 | 10 | function setupConfigure(){ |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | if (i === 0) { |
47 | 47 | li.className = 'selected'; |
48 | 48 | } |
49 | | - |
| 49 | + |
50 | 50 | var headers = children[i].getElementsByTagName( 'h2' ); |
51 | 51 | var tables = getElementsByClassName( children[i], 'table', 'configure-table' ); |
52 | 52 | |
— | — | @@ -79,7 +79,7 @@ |
80 | 80 | var ul = document.createElement( 'ul' ); |
81 | 81 | ul.style.display = "none"; |
82 | 82 | ul.id = "config-toc-" + i; |
83 | | - |
| 83 | + |
84 | 84 | for( var subsect = 0; subsect < len; subsect++ ){ |
85 | 85 | headers[subsect].id = 'config-head-' + i + '-' + subsect; |
86 | 86 | tables[subsect].id = 'config-table-' + i + '-' + subsect; |
— | — | @@ -235,26 +235,26 @@ |
236 | 236 | } |
237 | 237 | } |
238 | 238 | } |
239 | | - |
| 239 | + |
240 | 240 | /** Collapsible big lists */ |
241 | 241 | var biglists = getElementsByClassName( configform, '*', 'configure-biglist' ); |
242 | | - |
| 242 | + |
243 | 243 | for( var l = 0; l < biglists.length; l++ ) { |
244 | 244 | var list = biglists[l]; |
245 | | - |
| 245 | + |
246 | 246 | list.id = 'configure-biglist-content-'+l; |
247 | 247 | list.style.display = 'none'; |
248 | | - |
| 248 | + |
249 | 249 | var tn = document.createTextNode( wgConfigureBiglistHidden ); |
250 | 250 | var div = document.createElement( 'div' ); |
251 | 251 | var toggleLink = document.createElement( 'a' ); |
252 | | - |
| 252 | + |
253 | 253 | toggleLink.appendChild( document.createTextNode( wgConfigureBiglistShow ) ); |
254 | 254 | toggleLink.className = 'configure-biglist-toggle-link'; |
255 | 255 | toggleLink.onclick = createToggleCallback( l ); |
256 | 256 | toggleLink.id = 'configure-biglist-link-'+l; |
257 | 257 | toggleLink.href = 'javascript:'; |
258 | | - |
| 258 | + |
259 | 259 | div.id = 'configure-biglist-placeholder-'+l; |
260 | 260 | div.className = 'configure-biglist-placeholder'; |
261 | 261 | div.appendChild( tn ); |
— | — | @@ -268,43 +268,43 @@ |
269 | 269 | summariseSetting( list, summary ); |
270 | 270 | list.parentNode.insertBefore( summary, list ); |
271 | 271 | } |
272 | | - |
| 272 | + |
273 | 273 | /** Search box initialise */ |
274 | 274 | buildSearchIndex(); |
275 | | - |
| 275 | + |
276 | 276 | // Insert a little search form just before the configuration form |
277 | 277 | document.getElementById( 'configure-search-form' ).style.display = 'block'; |
278 | 278 | addHandler( document.getElementById( 'configure-search-input' ), 'keyup', function() { doSearch( this.value ); } ) |
279 | 279 | } |
280 | 280 | |
281 | 281 | function doSearch( query ) { |
282 | | - query = query.toLowerCase(); |
283 | | - |
| 282 | + query = document.getElementById( 'configure-search-input' ).value.toLowerCase(); |
| 283 | + |
284 | 284 | var results = document.getElementById( 'configure-search-results' ); |
285 | | - |
| 285 | + |
286 | 286 | // Empty the existing results |
287 | 287 | while( results.firstChild ) { |
288 | 288 | results.removeChild(results.firstChild); |
289 | 289 | } |
290 | | - |
| 290 | + |
291 | 291 | if ( query == '' ) { |
292 | 292 | return; |
293 | 293 | } |
294 | | - |
| 294 | + |
295 | 295 | var isMatch = function(element) { return element.description.indexOf( query ) !== -1; } |
296 | 296 | for( var i=0; i<allSettings.length; ++i ) { |
297 | 297 | var data = allSettings[i]; |
298 | 298 | if ( isMatch( data ) ) { |
299 | 299 | var a = document.createElement( 'a' ); |
300 | 300 | var li = document.createElement( 'li' ); |
301 | | - |
| 301 | + |
302 | 302 | a.href = '#config-head-'+data.fid+'-'+data.sid; |
303 | 303 | addHandler( a, 'click', configToggle ); |
304 | 304 | a.confSec = data.fid; |
305 | 305 | a.confSub = data.sid; |
306 | 306 | a.appendChild( document.createTextNode( data.displayDescription ) ); |
307 | 307 | li.appendChild( a ); |
308 | | - |
| 308 | + |
309 | 309 | results.appendChild( li ); |
310 | 310 | } |
311 | 311 | } |
— | — | @@ -312,7 +312,7 @@ |
313 | 313 | |
314 | 314 | function buildSearchIndex() { |
315 | 315 | allSettings = []; |
316 | | - |
| 316 | + |
317 | 317 | // For each section... |
318 | 318 | var rootElement = document.getElementById( 'configure' ); |
319 | 319 | var fieldsets = rootElement.getElementsByTagName( 'fieldset' ); |
— | — | @@ -329,28 +329,32 @@ |
330 | 330 | subsection = subsections[sid]; |
331 | 331 | } |
332 | 332 | var heading = document.getElementById( subsection.parentNode.id.replace( 'config-table', 'config-head' ) ); |
333 | | - |
| 333 | + |
334 | 334 | // For each setting... |
335 | 335 | for( var i=0; i<subsection.childNodes.length;++i ) { |
336 | | - |
337 | 336 | var row = subsection.childNodes[i]; |
338 | | - if ( row.nodeType != row.ELEMENT_NODE || ( row.tagName != 'tr' && row.tagName != 'TR' ) ) { |
| 337 | + if( typeof row.ELEMENT_NODE == "undefined" ){ |
| 338 | + var wantedType = 1; // ELEMENT_NODE |
| 339 | + } else { |
| 340 | + var wantedType = row.ELEMENT_NODE; |
| 341 | + } |
| 342 | + if ( row.nodeType != wantedType || ( row.tagName != 'tr' && row.tagName != 'TR' ) ) { |
339 | 343 | continue; |
340 | 344 | } |
341 | | - |
| 345 | + |
342 | 346 | var desc_cell = getElementsByClassName( row, 'td', 'configure-left-column' )[0]; |
343 | 347 | if( typeof desc_cell == "undefined" ){ |
344 | 348 | continue; |
345 | 349 | } |
346 | 350 | |
347 | 351 | var description; |
348 | | - |
| 352 | + |
349 | 353 | if ( desc_cell.getElementsByTagName( 'p' ).length ) { // Ward off comments like "This setting has been customised" |
350 | 354 | description = getInnerText( desc_cell.getElementsByTagName( 'p' )[0] ); |
351 | 355 | } else { |
352 | 356 | description = getInnerText( desc_cell ); |
353 | 357 | } |
354 | | - |
| 358 | + |
355 | 359 | allSettings.push( { 'description': description.toLowerCase(), 'fid':fid+1, 'sid':sid, 'displayDescription': description } ); |
356 | 360 | } |
357 | 361 | } |
— | — | @@ -363,12 +367,12 @@ |
364 | 368 | while(summary.firstChild) { |
365 | 369 | summary.removeChild(summary.firstChild); |
366 | 370 | } |
367 | | - |
| 371 | + |
368 | 372 | // Based on class, do something. |
369 | 373 | var elementType = ' '+div.className+' '; |
370 | | - |
| 374 | + |
371 | 375 | var isType = function(type) { return elementType.indexOf( ' '+type+' ' ) !== -1; } |
372 | | - |
| 376 | + |
373 | 377 | if (isType('assoc') ) { |
374 | 378 | // If it's too big to display as an associative array, it's too big to display as a summary. |
375 | 379 | } else if ( isType( 'ns-bool' ) || isType( 'ns-simple' ) || isType( 'group-bool-element' ) || isType( 'group-array-element' ) ) { |
— | — | @@ -377,39 +381,39 @@ |
378 | 382 | for( var i=0; i<labels.length; ++i ) { |
379 | 383 | var label = labels[i]; |
380 | 384 | var checkbox = document.getElementById( label.htmlFor ); |
381 | | - |
| 385 | + |
382 | 386 | if (checkbox.checked) { |
383 | 387 | matches.push( label.innerHTML ); // Yuck |
384 | 388 | } |
385 | 389 | } |
386 | | - |
| 390 | + |
387 | 391 | summary.innerHTML = matches.join( ', ' ); // Be aware of velociraptors. |
388 | 392 | } else if ( isType( 'ns-array' ) || isType( 'ns-text' ) || isType( 'configure-rate-limits-action' ) ) { |
389 | 393 | // Basic strategy: find all labels, and list the values of their corresponding inputs, if those inputs have a value |
390 | 394 | var header_key = undefined; |
391 | 395 | var header_value = undefined; |
392 | | - |
| 396 | + |
393 | 397 | var headers = div.getElementsByTagName( 'th' ); |
394 | 398 | header_key = getInnerText( headers[0] ); |
395 | 399 | header_value = getInnerText( headers[1] ); |
396 | | - |
| 400 | + |
397 | 401 | var table = document.createElement( 'table' ); |
398 | 402 | table.className = 'assoc'; |
399 | 403 | table.appendChild( document.createElement( 'tbody' ) ); |
400 | 404 | table = table.firstChild; |
401 | | - |
| 405 | + |
402 | 406 | var tr = document.createElement( 'tr' ); |
403 | 407 | var key_th = document.createElement( 'th' ); |
404 | 408 | var value_th = document.createElement( 'th' ); |
405 | 409 | key_th.appendChild( document.createTextNode( header_key ) ); |
406 | 410 | value_th.appendChild( document.createTextNode( header_value ) ); |
407 | | - |
| 411 | + |
408 | 412 | tr.appendChild( key_th ); |
409 | 413 | tr.appendChild( value_th ); |
410 | 414 | table.appendChild( tr ); |
411 | | - |
| 415 | + |
412 | 416 | var rows = false; |
413 | | - |
| 417 | + |
414 | 418 | if ( isType( 'configure-rate-limits-action' ) ) { |
415 | 419 | var allRows = div.getElementsByTagName( 'tr' ); |
416 | 420 | for( var i=0; i<allRows.length; ++i ) { |
— | — | @@ -420,24 +424,24 @@ |
421 | 425 | var typeDesc = getInnerText( row.getElementsByTagName( 'td' )[0] ); |
422 | 426 | var periodField = document.getElementById( row.id+'-period' ); |
423 | 427 | var countField = document.getElementById( row.id+'-count' ); |
424 | | - |
| 428 | + |
425 | 429 | if ( periodField && periodField.value>0 ) { |
426 | 430 | rows = true; |
427 | | - |
| 431 | + |
428 | 432 | tr = document.createElement( 'tr' ); |
429 | 433 | var key_td = document.createElement( 'td' ); |
430 | 434 | var value_td = document.createElement( 'td' ); |
431 | | - |
| 435 | + |
432 | 436 | // Create a cute summary. |
433 | 437 | var summ = wgConfigureThrottleSummary; |
434 | 438 | summ = summ.replace( '$1', countField.value ); |
435 | 439 | summ = summ.replace( '$2', periodField.value ); |
436 | 440 | key_td.appendChild( document.createTextNode( typeDesc ) ); |
437 | 441 | value_td.appendChild( document.createTextNode( summ ) ); |
438 | | - |
| 442 | + |
439 | 443 | tr.appendChild( key_td ); |
440 | 444 | tr.appendChild( value_td ); |
441 | | - |
| 445 | + |
442 | 446 | table.appendChild( tr ); |
443 | 447 | } |
444 | 448 | } |
— | — | @@ -446,25 +450,25 @@ |
447 | 451 | for( var i=0; i<labels.length; ++i ) { |
448 | 452 | var label = labels[i]; |
449 | 453 | var arrayfield = document.getElementById( label.htmlFor ); |
450 | | - |
| 454 | + |
451 | 455 | if ( arrayfield && arrayfield.value ) { |
452 | 456 | rows = true; |
453 | | - |
| 457 | + |
454 | 458 | tr = document.createElement( 'tr' ); |
455 | 459 | var key_td = document.createElement( 'td' ); |
456 | 460 | var value_td = document.createElement( 'td' ); |
457 | | - |
| 461 | + |
458 | 462 | key_td.appendChild( document.createTextNode( getInnerText( label ) ) ); |
459 | 463 | value_td.appendChild( document.createTextNode( arrayfield.value ) ); |
460 | | - |
| 464 | + |
461 | 465 | tr.appendChild( key_td ); |
462 | 466 | tr.appendChild( value_td ); |
463 | | - |
| 467 | + |
464 | 468 | table.appendChild( tr ); |
465 | 469 | } |
466 | 470 | } |
467 | 471 | } |
468 | | - |
| 472 | + |
469 | 473 | if (!rows) { |
470 | 474 | tr = document.createElement( 'tr' ); |
471 | 475 | var td = document.createElement( 'td' ); |
— | — | @@ -473,7 +477,7 @@ |
474 | 478 | tr.appendChild( td ); |
475 | 479 | table.appendChild( tr ); |
476 | 480 | } |
477 | | - |
| 481 | + |
478 | 482 | summary.appendChild( table ); |
479 | 483 | } else if ( isType( 'configure-rate-limits-action' ) ) { |
480 | 484 | } else { |
— | — | @@ -491,7 +495,7 @@ |
492 | 496 | var act; |
493 | 497 | var newLinkText; |
494 | 498 | var newPlaceholderText; |
495 | | - |
| 499 | + |
496 | 500 | if (toggleLink.firstChild.nodeValue == wgConfigureBiglistShow) { |
497 | 501 | act = 'show'; |
498 | 502 | newLinkText = wgConfigureBiglistHide; |
— | — | @@ -506,10 +510,10 @@ |
507 | 511 | summariseSetting( content, summary ); |
508 | 512 | newPlaceholderText = wgConfigureBiglistHidden |
509 | 513 | } |
510 | | - |
| 514 | + |
511 | 515 | toggleLink.removeChild( toggleLink.firstChild ); |
512 | 516 | toggleLink.appendChild( document.createTextNode( newLinkText ) ); |
513 | | - |
| 517 | + |
514 | 518 | div.removeChild( div.childNodes[1] ); |
515 | 519 | div.appendChild( document.createTextNode( newPlaceholderText ) ); |
516 | 520 | } |