I meant the actual visited() function that returns a number. Anyway, here's a simple/easy to break example of how a macro that does something similar to <<once>> might work using the visited() function.
Macro.add('once', {
tags : ['becomes', 'remains'],
handler : function () {
var $wrapper = $(document.createElement('span'));
var length = this.payload.length;
var visit = visited() - 1;
var className = 'macro-' + this.name;
var lastTag = this.payload[length-1].name;
var lastContent = this.payload[length-1].contents;
var content;
if (visit >= length){
content = (lastTag === 'remains') ? lastContent : '';
} else {
content = this.payload[visit].contents;
}
$wrapper
.wiki(content)
.addClass(className)
.appendTo(this.output);
}
});
Use it like this:
<<once>>\
Content to show on first visit.
<<becomes>>\
Content to show on next visit.
<<becomes>>\
Content to show on third visit.
<<remains>>\
Content to show on fourth visit and all subsequent visits.
<</once>>
I didn't look at Leon's original code, so it's very possible (likely) I'm missing some functionality that he had in his code, but this should work as a sexier replacement for
<<if visited() is X>>Blah blah blah<</if>>
if that's all you're really after. If you have the replace macros installed, you'll need to change the names of these macros if you want to try and use them as is.