* Finds a brush by its alias. * * @param {String} alias Brush alias. * @param {Boolean} showAlert Suppresses the alert if false. * @return {Brush} Returns bursh constructor if found, null otherwise.
(alias, showAlert)
| 657 | * @return {Brush} Returns bursh constructor if found, null otherwise. |
| 658 | */ |
| 659 | function findBrush(alias, showAlert) |
| 660 | { |
| 661 | var brushes = sh.vars.discoveredBrushes, |
| 662 | result = null |
| 663 | ; |
| 664 | |
| 665 | if (brushes == null) |
| 666 | { |
| 667 | brushes = {}; |
| 668 | |
| 669 | // Find all brushes |
| 670 | for (var brush in sh.brushes) |
| 671 | { |
| 672 | var info = sh.brushes[brush], |
| 673 | aliases = info.aliases |
| 674 | ; |
| 675 | |
| 676 | if (aliases == null) |
| 677 | continue; |
| 678 | |
| 679 | // keep the brush name |
| 680 | info.brushName = brush.toLowerCase(); |
| 681 | |
| 682 | for (var i = 0; i < aliases.length; i++) |
| 683 | brushes[aliases[i]] = brush; |
| 684 | } |
| 685 | |
| 686 | sh.vars.discoveredBrushes = brushes; |
| 687 | } |
| 688 | |
| 689 | result = sh.brushes[brushes[alias]]; |
| 690 | |
| 691 | if (result == null && showAlert != false) |
| 692 | alert(sh.config.strings.noBrush + alias); |
| 693 | |
| 694 | return result; |
| 695 | }; |
| 696 | |
| 697 | /** |
| 698 | * Executes a callback on each line and replaces each line with result from the callback. |