WoW Druid Macros

[[innerindex]]druid

Introduction

Continuing my Macro listings, I’ll post some Druid Macros! These macros are all thanks to World of Warcraft Druid Forum. I don’t play a druid on any server, yet the macros are pretty straightforward. If you have questions or suggestions…let me know and I’ll update/post them here.

Feral Macros

Ravage/Shred combo

If not in stealth mode, cast shred.  Otherwise, cast ravage.
1/cast [nostealth] Shred; [stealth] Ravage

Ravage/Shred/Ferocious Bite
If alt is pressed, cast Ferocious Bite. Otherwise if in stealth, cast Ravage. Otherwise cast Shred.

show Shred
/cast [modifier:alt] Ferocious Bite; [stealth] Ravage; Shred

Pounce/Rake combo
If not stealth cast rake, otherwise cast pounce.

/cast [nostealth] Rake; [stealth] Pounce

Pounce/Rake/Rip
If alt pressed, cast Rip. Otherwise if stealth cast Pounce. Otherwise cast Rake.

# show Rake
/cast [modifier:alt] Rip; [stealth] Pounce; Rake

Pounce/Mangle combo - Note the extra ()
If not stealth cast Mangle, otherwise cast Pounce.

/cast [nostealth] Mangle (Cat)(); [stealth] Pounce

Prowl or Faerie Fire (Feral)
If out of combat and not stealthed, cast Prowl. Otherwise if in combat and not stealthed, cast Faerie Fire.

/cast [nocombat, nostealth] Prowl; [combat, nostealth] Faerie Fire (Feral)()

Maul/Mangle
This is a space saver macro! In combat, Mauls first, then Mangles, then Mauls, then Mauls. Each 'spell' requires a click.

/castsequence reset=6/combat Maul, Mangle (Bear)(), Maul, Maul

Mangle (Bear) replacing auto-attack
Starts off auto attack with a Mangle...if Alt is held while clicking the macro, you will stop attacking.

# show Mangle (Bear)()
/startattack [nomodifier:alt]
/cast [nomodifier:alt] Mangle (Bear)()
/stopattack [modifier:alt]

Shifting Macros

Shift to Caster
Shift to Caster Form from any form

/cancelaura [stance:1] Dire Bear Form; [stance:2] Aquatic Form; [stance:3] Cat Form; [stance:4] Travel Form; [stance:5] Moonkin Form <or Tree of Life>
/cancelaura [mounted] Frostwolf Howler <replace with your mount>

Shift to Dire Bear
Shift to Dire Bear Form from any form - note: to have this macro also de-shift you, include "[stance:1] Dire Bear Form; " somewhere in the /cancelaura line.

/cancelaura [stance:2] Aquatic Form; [stance:3] Cat Form; [stance:4] Travel Form; [stance:5] Moonkin Form <or Tree of Life>
/cancelaura [mounted] Frostwolf Howler <replace with your mount>
/cast [nostance] Dire Bear Form

Shift to Dire Bear and Charge
Shift to Dire Bear From and Feral Charge from any form

/cancelaura [stance:2] Aquatic Form; [stance:3] Cat Form; [stance:4] Travel Form; [stance:5] Moonkin Form <or Tree of Life>
/cancelaura [mounted] Frostwolf Howler <replace with your mount>
/cast [nostance] Dire Bear Form; [stance:1] Feral Charge

Dire Bear and Equip
Shift to Dire Bear Form and equip Idol/Weapon
* "Shift to Dire Bear From from any form, equip Warden Staff and Idol of Brutality only when you actually shift to Dire Bear. Note that the test for the equip is still [nostance] because it hasn't yet registered that the stance has changed. You don't need to worry about the global cooldown, because the stance change and the weapon equip both trigger it at the same time, so you only suffer once. (...equipping things can be done during global cooldown.) "

/cancelaura [stance:2] Aquatic Form; [stance:3] Cat Form; [stance:4] Travel Form; [stance:5] Moonkin Form <or Tree of Life>
/cancelaura [mounted] Frostwolf Howler <replace with your mount>
/cast [nostance] Dire Bear Form;
/equip [nostance] Warden Staff
/equip [nostance] Idol of Brutality

To Cat Form
Shift to Cat Form from any form - note: to have this macro also de-shift you, include "[stance:3] Cat Form; " somewhere in the /cancelaura line.

/cancelaura [stance:1] Dire Bear Form; [stance:2] Aquatic Form; [stance:4] Travel Form; [stance:5] Moonkin Form <or Tree of Life>
/cancelaura [mounted] Frostwolf Howler <replace with your mount>
/cast [nostance] Cat Form

To Cat and Stealth
Shift to Cat Form and stealth from any form (first line makes the macro display the Prowl cooldown)

show Prowl
/cancelaura [stance:1] Dire Bear Form; [stance:2] Aquatic Form; [stance:4] Travel Form; [stance:5] Moonkin Form <or Tree of Life>
/cancelaura [mounted] Frostwolf Howler <replace with your mount>
/cast [nostance] Cat Form; [stance:3, nostealth] Prowl

Shift to Cat Form and equip Idol
Switch from any form to Cat form and equip an Idol

/cancelaura [stance:1] Dire Bear Form;[stance:2] Aquatic Form; [stance:4] Travel Form; [stance:5] Moonkin Form <or Tree of Life>
/cancelaura [mounted] Frostwolf Howler <replace with your mount>
/cast [nostance] Cat Form; [stance:3, nostealth] Prowl
/equip [nostance] Idol of Ferocity

Shift to Travel Form from any form
Self Explanatory

/cancelaura [stance:1] Dire Bear Form; [stance:2] Aquatic Form; [stance:3] Cat Form; [stance:5] Moonkin Form <or Tree of Life>
/cancelaura [mounted] Frostwolf Howler <replace with your mount>
/cast [nostance] Travel Form

Travel Form + Nature's Grasp - note: you can cast Nature's Grasp in forms
If you are in a non-travel form, cancel it. If you are mounted, dismount. Cast Travel Form, cast Nature's Grasp.

/cancelaura [stance:1] Dire Bear Form; [stance:2] Aquatic Form; [stance:3] Cat Form; [stance:5] Moonkin Form <or Tree of Life>
/cancelaura [mounted] Frostwolf Howler <replace with your mount>
/cast [nostance, outdoors] Travel Form; [stance:4, outdoors] Nature's Grasp

Spam Travel Form
If you are in a non-travel form, cancel it. If you are mounted, dismount. Cast Travel Form.

/cancelaura [stance:1] Dire Bear Form; [stance:2] Aquatic Form; [stance:3] Cat Form; [stance:4] Travel Form; [stance:5] Moonkin Form <or Tree of Life>
/cancelaura [mounted] Frostwolf Howler <replace with your mount>
/cast [nostance, outdoors] Travel Form

All-Terrain Travel Form
If you are in a non-travel/non-swimming form, cancel it. If you are mounted, dismount. If you are swimming, cast Aquatic Form. Otherwise cast Travel Form.

/cancelaura [stance:1] Dire Bear Form; [stance:3] Cat Form; [stance:5] Moonkin Form <or Tree of Life>
/cancelaura [mounted] Frostwolf Howler <replace with your mount>
/cast [nostance, swimming] Aquatic Form; [nostance, outdoors] Travel Form

Spam All-Terrain Travel Form
No matter the current form, cancel it. If you are mounted, dismount. If you are swimming, cast Aquatic Form. Otherwise cast Travel Form.

/cancelaura [stance:1] Dire Bear Form; [stance:2] Aquatic Form; [stance:3] Cat Form; [stance:4] Travel Form; [stance:5] Moonkin Form <or Tree of Life>
/cancelaura [mounted] Frostwolf Howler <replace with your mount>
/cast [nostance, swimming] Aquatic Form; [nostance, outdoors] Travel Form

Spam ATTF + Mount
If you are in a non-travel/non-swimming form, cancel it. If you are standing still, mount. If you are swimming, cast Aquatic Form. Otherwise cast Travel Form.

/cancelaura [stance:1] Dire Bear Form; [stance:2] Aquatic Form; [stance:3] Cat Form; [stance:4] Travel Form; [stance:5] Moonkin Form <or Tree of Life>
/use Stormpike Battle Charger <replace with your mount>
/cast [nostance, swimming] Aquatic Form; [nostance, outdoors] Travel Form

Spam Travel Form + Rejuv - the WSG flag carrying macro
Cancel any form. If you are mounted, unmount. Cast rejuvenation, travel form, travel form, travel form (one per button press in that order).

/cancelaura [stance:1] Dire Bear Form; [stance:2] Aquatic Form; [stance:3] Cat Form; [stance:4] Travel Form; [stance:5] Moonkin Form <or Tree of Life>; [mounted] Frostwolf Howler <replace with your mount>
/castsequence [nostance] reset=12 Rejuvenation, Travel Form, Travel Form, Travel Form

Shift to Tree of Life form and switch your actionbar from #1, to #2
Since most spells don't work in Tree of Life, you can set up a dedicated actionbar with ToL-only spells.

/cancelaura [stance:1] Dire Bear Form; [stance:2] Aquatic Form; [stance:3] Cat Form; [stance:4] Travel Form
/cancelaura [mounted] Frostwolf Howler <replace with your mount>
/cast [nostance] Tree of Life
/changeactionbar [stance:5] 2

Return to Caster Form and restore original actionbar

/cancelaura [stance:1] Dire Bear Form; [stance:2] Aquatic Form; [stance:3] Cat Form; [stance:4] Travel Form; [stance:5] Tree of Life
/cancelaura [mounted] Frostwolf Howler <replace with your mount>
/changeactionbar [nostance] 1 

Restoration Macros

Cleanse Poison/Curse Combo

#left click abolish poison, right click remove curse. both find target, alternatively, if you prefer targeting player first, replace target=none with target=target
/cast [button:1,target=none] Abolish Poison; [button:2,target=none] Remove Curse

Spam Cleanses

/targetfriend
/cast [button:1] Cure Poison; [button:2] Remove Curse
/stopcasting

Pseudo -Decursive

/cast [help] Cure Poison
/stopcasting
/cast [target=player] Cure Poison
/cast [target=party1] Cure Poison
/cast [target=party2] Cure Poison
/cast [target=party3] Cure Poison
/cast [target=party4] Cure Poison
/stopcasting

Nature's Swiftness + Healing Touch

/cast Nature's Swiftness
/stopcasting
/cast [help] Healing Touch; [target=player] Healing Touch

NS + HT/Regrowth

/cast Nature's Swiftness
/stopcasting
/cast [nostance, help] Healing Touch; [nostance, target=player] Healing Touch; [stance:5, help] Regrowth; [stance:5, target=player] Regrowth

ZHC + NS + HT/Regrowth

/use Zandalarian Hero Charm
/stopcasting
/cast Nature's Swiftness
/stopcasting
/cast [nostance, help] Healing Touch; [nostance, target=player] Healing Touch; [stance:5, help] Regrowth; [stance:5, target=player] Regrowth

Heal target or self, based on context

/cast [help] Healing Touch; [target=player] Healing Touch
/stopmacro [nohelp]
/say "Healing %t in 3 seconds."

HoT Stack

/castsequence [help] reset=8/target Regrowth, Rejuvenation, Lifebloom; [target=player] reset=8 Regrowth, Rejuvination, Lifebloom

Rejuv + Idol

/equip Idol of Rejuvenation
/cast Rejuvenation

Heal Target or Target's target

/cast [help] Healing Touch; [target=targettarget] Healing Touch

Healing Touch Mega-pack

/cast [modifier:alt,target=player] Healing Touch;[help] Healing Touch;[target=targettarget, help] Healing Touch;[target=mouseover,help] Healing Touch;[target=focus,help] Healing Touch;[target=focustarget,help];[target=none] Healing Touch 

General Utility Macros

Faerie Fire and Feral Faerie Fire combo

show Faerie Fire (Feral)()
/cast [nostance] Faerie Fire; Faerie Fire (Feral)()

Spammable Prowl and Shadowmeld

/cast [nocombat, stance:3, nostealth] Prowl; [nocombat, nostealth] Shadowmeld

Innervate - note: Innervate supposedly can now only be cast on units with mana.

/cast [modifier:alt, target=player] Innervate; [help] Innervate; [target=mouseover, exists, help] Innervate; [target=none] Innervate

Moonfire Spam
Cast Moonfire rank 10, 9, 9, 9, 9 each time the button is pressed. Reset the macro if you change targets, enter combat, or hold ctrl and press the macro.

/castsequence reset=9/target/combat/ctrl Moonfire(Rank 10), Moonfire(Rank 9), Moonfire(Rank 9), Moonfire(Rank 9), Moonfire(Rank 9)

Moonfire Flex
If you hold control, cast moonfire 1. If you click with your second mouse button, cast rank 9, otherwise cast rank 10.

/cast [modifier:ctrl] Moonfire(Rank 1); [button:2] Moonfire(Rank 9); Moonfire(Rank 10)

Moonfire + Idol

/equip Idol of the Moon
/cast Moonfire

Totem Killer - needs testing

/target totem
/cast [harm] Moonfire(Rank 1)

Faerie Fire Target or Target's target

/cast [harm] Faerie Fire; [target=targettarget, harm] Faerie Fire

Hurricane+Barkskin - note: for some reason, this still show's Barkskin's cooldown

show Hurricane
/stopmacro [channeling:Hurricane]
/castsequence reset=60/combat Barkskin, Hurricane

Gift of the Wild/Mark of the Wild

/cast [button:2] Gift of the Wild; [modifer:ctrl] Gift of the Wild; Mark of the Wild

Mark of the Wild + Thorns

/castsequence [modifier:alt, target=player] reset=10/target Thorns, Mark of the Wild; [help] reset=10/target Thorns, Mark of the Wild; [target=player] reset=10/target Thorns, Mark of the Wild

Stun and Self-Heal (Tauren)

show War Stomp
/cancelaura [stance:1] Dire Bear Form; [stance:2] Aquatic Form; [stance:3] Cat Form; [stance:4] Travel Form; [stance:5] Moonkin Form <or Tree of Life>
/castsequence [target=player] reset=120/combat War Stomp, Regrowth, Rejuvenation

Stun and Self-Heal (Dire Bear Form) - doesn't work yet...

show Bash
/cancelaura [stance:2] Aquatic Form; [stance:3] Cat Form; [stance:4] Travel Form; [stance:5] Moonkin Form <or Tree of Life>
/castsequence [stance:1] reset=50/combat Bash, Dire Bear Form, Regrowth, Rejuvenation
/castsequence [nostance] reset=50/combat Dire Bear Form, Bash, Dire Bear Form, Regrowth, Rejuvenation

WoW Priest Macros

[[innerindex]]priest

Introduction

Using my post on macros, World of Warcraft Forums and a number of other random resources and suggestions, I’ll be posting useful macros for each class. Because I play a Priest on Illidan, I’ll start with that class first :).

Crowd Control Macros

Shackle version 1
This macro will cast Shackle Undead if the target is hostile. It will then tell the party that you’re shacking the target. The stopmacro line will prevent the announcement if the target is not hostile, cutting down on unnecessary spam. However, I think you’ll still get a /p message if you attempt to cast shackle undead on a non-valid target. (confirmed for 2.0.1)

/cast [harm] Shackle Undead
/stopmacro [noharm]
/p Shackling %t! DO NOT TOUCH!

Shackle version 2 (Focus Combo)
Allows you to set your focus and bind a spell directly to that focus. You should be able to cast the second spell without ever losing your current target. If used with a heal spell instead of shackle, this should also be very helpful for MT/Raid healing.

macro 1: 
/focus target
macro 2: 
/cast [target=focus,harm] Shackle Undead; [harm] Shackle Undead
/stopmacro [target=focus,noharm]
/script SendChatMessage(UnitName("focus").." is shackled! DO NOT BREAK!") 

Note: if you don’t know what /focus target does…well, it allows you to mark a target as a focused target which allows you to target other objects and cast spells on that focus without losing your current target.

Healing Macros

Simple Greater Heal
This simple macro will cast Greater Heal (the highest rank you have) if the target is friendly, and alert the party about whom you’re healing. It will stop the announcement if the target is not friendly. (confirmed for 2.0.1)

/cast [help] Greater Heal
/stopmacro [nohelp]
/p Healing %t 

Target/Self Heal Macro
This macro checks to see if you have the “alt” key selected – if you do, then it casts Flash Heal on yourself. If you do not, it wil cast Flash Heal on your friendly target. It also announces to the party when you heal a target.

/cast [modifier:alt,target=player] Flash Heal; [help] Flash Heal
/p Healing %t 

A Better Target/Self Healing Macro
Llenyd and Augur wrote this one, which I think is better than the one listed above. It will heal yourself if the target is harmful, otherwise it will heal your target – and announce whomever you’re healing, including yourself. The above macro would only announce your targetted healing. (confirmed for 2.0.1)

/cast [help] <healing Spell>; [target=player] <healing Spell>
/script local n if(UnitIsFriend("player","target")) then n=UnitName("target") else n=UnitName("player") end SendChatMessage("Healing"..n.."in 3 seconds","SAY",nil) 

Uber Mouse Wielding Heal Macro
For you uber-mouse wielders out there, Llenyd’s macro would:
Cast GH1 on the Broodlord’s current target if you click the macro.
Cast Shield on the Broodlord’s current target if you right-click the macro.
Cast highest rank FH on the Broodlord’s current target if you Mouse Button 4-click the macro.
Cast highest rank GH on the Broodlord’s current target if you Mouse Button 5-click the macro.

/cast [target=targettarget, button:1] Greater Heal (Rank 1); [target=targettarget, button:2] Power Word: Shield; [target=targettarget, button:4] Flash Heal; [target=targettarget; button:5] Greater Heal 

Uber Mouse Wielding Flash Heal Macro
This is similar to the above macro, except that it casts Flash Heal and chooses the targets according to which mouse button you click with.

/cast [button:1, help] Flash Heal; [button:1, harm, target=targettarget] Flash Heal; [modifier:alt, target=player] Flash Heal; [button:2, target=party2] Flash Heal; [button:3, target=party3] Flash Heal; [button:4, target=party4] Flash Heal; [button:5, target=party5] Flash Heal 

Combat Macros

Space Saving Mind Blast/SW:Pain Macro
This macro uses the new “cast sequence” ability – yay more bar space! When you first click it, it should cast Mind Blast – when you click the button again, it will cast Shadow Word: Pain. The sequence will reset to Mind Blast if the player drops out of combat, or chooses a different target.

/castsequence reset=combat/target Mind Blast, Shadow Word: Pain 

MindFlay When Not Channeling Macro
Should cast Mind Flay only if you are not currently already channeling Mind Flay. For those “duh” moments. :)

/cast [nochanneling:Mind Flay] Mind Flay

Devouring Plague Macro
Good example of the timed reset macro. This macro will, on the first button press, cast Inner Focus. On the second press, it will cast Devouring Plague. The sequence resets after Devouring Plague, or if enough time passes between button presses (170).

/castsequence reset=170 Inner Focus, Devouring Plague

Shadowform Heal
For our shadow friends, this macro will drop shadowform on the first click, cast Flash Heal on the second click, and revert you to shadowform on the third click. If you are not in shadowform, it won’t do anything.

/castsequence [stance:1] Shadowform, Flash Heal, Shadowform

Correct Your Smiting
Casts smite on a harmful target…OR if you target a friendly to heal them, and they’re targeting a mob, casts smite on your target’s target.

/cast [harm] Smite; [target=targettarget, harm] Smite

Troll Berserking/PI/IF Macro
Sirona’s Troll Berserking / Power Infusion / Inner Focus — Smite macro does just what it says. :) If any of the first spells are on cooldown it should give you an error message, but continue on through the other spells. You can also turn this into a healing macro if you change the final spell.

/cast Berserking
/stopcasting
/cast Power Infusion
/stopcasting
/cast Inner Focus
/stopcasting
/cast Smite 

Misc Macros

Mouseover Dispell
Sylphael’s macro (ty, Sylphael!) will cast dispel magic on whatever target your mouse is presently hovering over. So if you bind it to a mouse button and hit that button while hovering over a character, you’ll cast dispel on that character.

/cast [target=mouseover] Dispel Magic

Instant Shield
This will stop the current spell and cast PW:S on your target if it is friendly, or (if that fails) it will cast PW:S on your target’s target.

/stopcasting
/cast [help] Power Word: Shield; [target=targettarget] Power Word: Shield 

Handy Resurrection Macro
Just a simple resurrection macro that announces your casting!

/cast [dead] Resurrection
/stopmacro [nodead]
/script SendChatMessage("Resurrecting "..UnitName("target")..".  w00t!")

Top Trinket+PI Macro
This is Tanara’s “Top Trinket +PI” macro. Trinket slots will not be a valid term in the “/castsequence” macros – you’ll have to specify the item name like the one in italics here. If I remember right, the name is case sensitive but only has to be long enough so that the term isn’t ambiguous. For example, “Conjured” could call conjured water or conjured cinnamon roll. You would have to write out to “Conjured Cinn” to get the term non-ambiguous.

The macro is a sequence so that if the trinket was on cooldown, then the Power Infusion wouldn’t cast. There’s no way to “use spell if item is not on cooldown” in the new scripting language – the developers deliberately removed that functionality. Remember, you’ll have to press the button twice (with no failure) to get the Power Infusion spell cast.

/castsequence [target=player] Zandalarian Hero Charm, Power Infusion

Spoon’s BAM Macro
Spoon’s BAM macro (ty Spoon!) should use the Hero Charm if it’s not on cooldown, then cast Power Infusion, then cast Inner Focus – all with one click. It differs from the above macro in that there’s no cooldown check. If the Hero Charm is on cooldown, you’ll just receive an error message but the rest of the spells will execute.

/use Zandalarian Hero Charm
/stopcasting
/cast [target=player] Power Infusion
/stopcasting
/cast [target=player] Inner Focus

SpaceSaver Macro
Spoon’s spacesaver macros – now your low ranked or single-cast spell can be the same button as your high ranked. All you’ll have to do is hold the alt key to toggle between them.

/cast [modifier:alt] Prayer of Shadow Protection; Shadow Protection
/cast [modifier:alt] Greater Heal(Rank 1); Greater Heal
/cast [modifier:alt] Holy Nova(Rank 1); Holy Nova

Raid Shield
Pretty simple macro to cast shield on your target if he’s in your group and friendly or if your target’s target is friendly and in group, or else shield yourself.

/cast [raid] Power Word: Shield; [target=targettarget, raid] Power Word: Shield; [target=player] Power Word: Shield

Special thanks to Anaea of Aerie Peak’s Priest Macro resource where a number of macros were pilfered :)

JavaScript Shell

While at The Ajax Experience I noticed a tool that a few of the speakers made use of that was missing from my arsenal. The tool? JavaScript Shell.

This little beauty, once you’ve added the bookmark to your browser allows you to open a JavaScript Shell for any page you happen to be on! The shell lets you enter JavaScript from command-line to manipulate the page, trigger functions, analyze properties, etc. All libraries that the site has loaded are available within the Shell…so, if you use jQuery or some other toolkit, all defined functions and plugins are usable.

Here’s some features and pre-defined functions from the JavaScript Shell site

Features

  • You can enter statements and expressions at the same prompt.
  • The result of each non-void statement or expression is shown.
  • User-defined variables.
    • b = document.body
  • User-defined functions.
    • function f() { return 5; }
  • JavaScript error messages are shown in red.
  • Previous statements and expressions are available through Up and Down arrow keys.
  • Tab completion.
  • Multiline input (Shift+Enter to insert a line break).
  • If the shell is opened using a bookmarklet, JavaScript typed into the shell runs in the context of the original window.
  • Works well in Firefox, mostly works in Opera 8 and in IE 6 for Windows.

Built-in functions

  • ans: the result of the previous expression.
  • print(expr): prints expr on its own line.
    • for(i = 0; i < 6; ++i) print(i * i)
  • pr(expr): prints and returns its input, so you can use it to print intermediate results in the middle of an expression.
    • function fact(n) { return n>0 ? pr(n*fact(n-1)) : 1 }
  • blink(node) or Alt+B: makes a node blink for a second.
    • blink(document.links[3])
  • props(obj) or Alt+P: lists the methods and fields of an object.
    • props(document.body)
    • In Firefox, props also shows which properties belong to the object itself and which belong to objects in its prototype chain.

I’m a fan :D

Prototype Makes Javascript Painless

prototype.gifPrototype is an excellent tool but lacking in documentation, causing me to fumble around and *gasp* look at the source code. As any developer knows, when reviewing code there is a chance that you may miss something or ignore what doesn’t seem interesting. In doing so, you may miss some sweet features that you would otherwise use.

I did stumble upon some Prototype Cheat Sheets that have helped immensely in exposing functions that existed in Prototype that I had no clue were there. Desipte the exposure of function names, I was at a loss for what some of them did. Luckily, there is an article over at SergioPeriera.com that documents many of those functions! The documentation is fairly solid so I HIGHLY reccommend checking it out. Here’s one of the features of Prototype that I had seen the function but hadn’t a firm understanding on what it did:

Try.these()
Tries a number of functions in order. If the first fails, it attempts the second, and so on.

function getXmlNodeValue(xmlNode){
	return Try.these(
		function() {return xmlNode.text;},
		function() {return xmlNode.textContent;)
		);
}

Hugely cool. In addition, Ajaxian – which seems to be my source for many things Ajax – has pointed me towards this article over at SitePoint. I was aware of a number of the points mentioned in that SitePoint article, but a few stood out as super sexy. Here’s the juicy tidbits:

String.times([something])
Prototype adds a great method to Number, too. Say goodbye to your for loops!

// alerts "1", "2", "3" ... "50"
(50).times(function(n) { alert(n); });

Enumberable.each([something])
This does the same as a foreach in PHP. I’ve been looking for something like this!

// alerts "a is at 0" then "b is at 1" then "c is at 2"
["a", "b", "c"].each(function(item, index) {
 alert(item + " is at " + index);
});

Iterating over childNodes in the DOM
By default, even though nodes are represented in Array-like form, they do not have Enumerable available to them automatically. Here’s how to do it:

// add Enumerable to childNodes
var children = $A($("mydiv").childNodes);

// sets class="highlighted" for all child nodes of "mydiv"
children.each(function(child) {
 child.setAttribute("class", "highlighted");
});

Here’s one I found while digging around in the Prototype code that the article solidified my understanding:

Ajax.PeriodicalUpdater(id,file,options)
Periodically does an Ajax.Updater call!

new Ajax.PeriodicalUpdater("mydiv", "hello.php", {
 // initial number of seconds interval between calls
 frequency : 1,
 decay : 2
});

The decay option allows you to give your server a bit of a break if it’s returning a lot of identical responses. Essentially, every time PeriodicalUpdater makes a request, it compares the results with what the server returned last time. If the values are the same, it multiplies the interval by the decay value. So, for the above example, it would make the next request two seconds later, then four seconds later, and so on, until it received a different result from the server. At that point, the interval would be reset to one second.

Ajax.Responders.register(options)
Register global event handlers that are triggered for each and every AJAX request that happens on the page.

Ajax.Responders.register({
 onCreate : showLoader,
 onComplete : hideLoader
});