Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

SugarCube - how to using TheMadExile popup macro

recently i searching for method for how to make a popup in SugarCube and i have this
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

  • That's not my macro (Claretta wrote it, not I).  Beyond that, the macro in question was not written to accept a wiki link as an argument, the link text and the passage name are given separately.  For example:
    <<popup "link text" "passage name">>
  • TheMadExile wrote:

    That's not my macro (Claretta wrote it, not I).  Beyond that, the macro in question was not written to accept a wiki link as an argument, the link text and the passage name are given separately.  For example:
    <<popup "link text" "passage name">>


    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.
  • [quote] (Claretta wrote it, not I)

    Damn! I would have said "not me"

    #iJustGotSchooled
  • edited September 2015
    Sorry to bump this thread but I'm trying to use this macro and it's not working. It gives me an error-
    "Error [user-script-node-1]: undefined is not a function."

    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.
  • The version of the <<popup>> macro in this thread require a HTML element with the ID of ui-body to work, and that element does not exist in SugarCube 2.

    Try the version in this comment instead.
  • greyelf wrote: »
    The version of the <<popup>> macro in this thread require a HTML element with the ID of ui-body to work, and that element does not exist in SugarCube 2.

    Try the version in this comment instead.

    Thanks
Sign In or Register to comment.