It looks like you're new here. If you want to get involved, click one of these buttons!
macros.add("popup", {
version: { major: 1, minor: 0, revision: 0 },
handler: function ()
{
if (this.args.length < 2)
{
var errors = [];
if (this.args.length < 1) { errors.push("link text"); }
if (this.args.length < 2) { errors.push("passage name"); }
return this.error("no " + errors.join(" or ") + " specified");
}
var el = document.createElement("a");
el.innerHTML = this.args[0];
el.className = "link-internal link-popup";
el.setAttribute("data-passage", this.args[1]);
UISystem.addClickHandler(el, null, function(evt) {
var dialog = document.getElementById("ui-body");
$(dialog)
.empty()
.addClass("dialog popup");
new Wikifier(dialog, tale.get(evt.target.getAttribute("data-passage")).processText().trim());
return true;
});
this.output.appendChild(el);
}
});
but how to use it ? because when i type
<<popup [[text|popPassage]]>>
or
<<popup [[text|popPassage][trythis]]>>
its return same Error: <<popup>>: no passage name specified
Comments
oh i'm truly sorry about that, i don't know if that's not your code sir and thanks for the example code, it's works great.
Damn! I would have said "not me"
#iJustGotSchooled
I don't get errors when this javascript isn't in. It happens even if it's the only thing in the javascript section. Anyone have any ideas?
It even happens in a brand new story. I'm using Sugarcube 2.
Try the version in this comment instead.
Thanks