0 votes
by (280 points)

I made key binding macro for link action

but I have no idea with replace macros

Macro.add('key', {
	handler:function(){
		var input = this.args[0].toUpperCase();
		var linktext = this.args[1];
		
		if(this.args.length==2)
			{var link = this.args[1]}
		else if(this.args.length==3)
			{var link = this.args[2]}
		
		var result = '<a id="'+link+'" data-passage="'+link+'">'+linktext+'</a> ('+input+')'
		
		$(this.output).wiki(result);
		if (input == '↩'){input = 'BACKSPACE'}
		if (input == '↲'){input = 'ENTER'}
		if (input.toUpperCase() == 'ESC'){input = 'ESCAPE'}
		$(document).on('keyup', function (ev) {
			if (ev.key.toUpperCase() == input){				$('a#'+link).click()}
		});
	}
});

 

and use like this in passage

<<key '↲' '[Ok with this]' 'MainPage'>>

 

but with replace macro

<<key 'Esc' '[Change] <<replace "#NewHero">><<set $Char.pop()>><<include "CHero">><</replace>>' '??'>>

what can I do with this problem..

I tried to if when args[2] is 'null' then pass "data-passage=link" but it doesn't work

Please log in or register to answer this question.

...