Spyke
perchance·Perchance - Create a Random Text Generatorby_afb

nested plugin: does anybody know how to reference the currently selected node in a different place on the page?

It's great if the author of the nested plugin is reading this, but even if you aren't the author I hope you read this.

Thank you.

Questions for experienced Perchance users in general

  • When you are figuring out how to pull some piece of data out of an object created by a Perchance plugin, how do you figure out what the Javascript name of that object is?
  • Is there some standard way of figuring out which account maintains a Perchance plugin is if their name is not displayed on the plugin's page?

Question for people familiar with using the nested plugin (or its author)

This is a location generator for a fictional world I'm working on. I am trying to create a second panel in the web page that show the currently selected item in the nested hierarchy at the top and show the description fields from the entire chain leading to it.

In this mockup I have a static div at the bottom with placeholder text saying "Star description. Celestial body description. Feature description. Region or point-of-interest description."

I would like it to dynamically pull the description attributes of the currently selected node and the entire chain of nodes leading to it. So, it would look like this...

A late-epoch system around a red dwarf: compact, old, and far more typical than Sun-like systems in PW50B. >> The surface regime here is defined by frost, fracture, and deep cold rather than rain, rivers, or active seas. >> The object is small enough that shape, mass distribution, and surface coherence have all given up on elegance. >> This is terrain that has lost coherence, becoming a field of fragments rather than a single intact crust.

... which is what the descriptions leading from the root to the currently selected node say.

By the way, is there a way to display the description field of a non-terminal node besides in a tooltip?

nested plugin: does anybody know how to reference the currently selected node in a different place on the page?https://perchance.org/t9sj89t8pl#editOpen linkView original on lemmy.world
  • When you are figuring out how to pull some piece of data out of an object created by a Perchance plugin, how do you figure out what the Javascript name of that object is?
    • Not sure I understand correctly. Do you want to extract a list out of a plugin? Then something like this should do the trick: "root.$moduleSpace["nested-plugin"].world". Or do you want to understand how to find it? I do that through inspecting the root object in the browser console
  • Is there some standard way of figuring out which account maintains a Perchance plugin is if their name is not displayed on the plugin’s page?
    • Not that I know of

Now to your main problem: Afaik, perchance objects are static and don't save their state when they're evaluated. You have to inspect the DOM with JavaScript and traverse the parent elements to gather all descriptions. At least that's how I got it https://perchance.org/ah70cbqlqk#edit

I'm not really good at explaining, please ask if something is unclear. What I've done in the example is, I've overwritten the javascript onclick handler defined in the nested-plugin. This onclick handler is executed when expanding a header element. This allowed me to inspect the DOM that was generated through the nested-plugin. If the currently expanding element is a leaf, it traverses each parent header element and extracts the description of it and overwrites the content with all gathered descriptions.

2

I’m not really good at explaining, please ask if something is unclear. What I’ve done in the example is, I’ve overwritten the javascript onclick handler defined in the nested-plugin.

Thank you! You are better at explaining than you think. Yes, this definitely looks like what I'm trying to achieve. I'll try it and post an update on how it goes.

2

You reached the end

nested plugin: does anybody know how to reference the currently selected node in a different place on the page? | Spyke