Preference window for userscripts

By devnull69 Last update Sep 30, 2009 — Installed 8,459 times.

Handling Arrays?

in
Subscribe to Handling Arrays? 7 posts, 2 voices



IzzySoft Scriptwright

Hiho,

first: Great idea - I'm just looking for something like that! Any chance to handle arrays with it? To give an example: Have a look at this script. Right now, most configuration needs to take place in the file itself, which I want to move to a GUI. So I need e.g. to let the user manipulate the list of search terms, like:

searchTerms = ("one","two","three");

Now in the GUI, the user should be able to add items to or remove them from that array. From the "visual side", this could be a multi-select box: Click one or more items (by holding the Ctrl or Shift keys), then click a button next to this to remove. Enter a new value into some input element next to it, and click a button to add.

Possible? Are you going to implement something like this?

Thankx in advance (at least to your reply - even more if it is "Yes" Excited),
Izzy.

 
devnull69 Script's Author

I'm thinking about it ...

I think one would need the stored values as an array when USP.getValue is called ...

Perhaps I can handle this by using an Array for "theDefault" and then show a multiselect box. And store the values as a JSON-String ...

I will give it some more thoughts

 
IzzySoft Scriptwright

That's like the (only) other project does it (JSON storage - check the groups for GM_config to see yourself). Though I must admit there are three things I like more with your script: It uses GM_get/setValue with the original values (so I can even read/write them without the GUI being present), the style (dark layer etc. to make clear what's going on), and the easier-to-call. But the (a little bit more difficult) syntax for calling the other script also has a clear advantage: More flexibility...

However: It's always good to have alternatives available. And when they use different approaches: What does not fit the one, is fine for the other.

So keep up the good job, and all the best for it! I'm looking forward to its future Cool

 
devnull69 Script's Author

Just to keep you up to date ...

The script is beginning to get shape concerning the array handling. Storing, retrieving and displaying is already working. Now I have to work on the editing part.

 
IzzySoft Scriptwright

Glad to read - thanks for the update! May I invite you to the GM_config Developers group to share ideas? Maybe you even find some useful code to adapt there Tongue

 
devnull69 Script's Author

Done.

Perhaps you can take a look at it or maybe even test it a bit before I set it to version 1.0.0

Thanks!

 
IzzySoft Scriptwright

Will do so ASAP. Thank you!

Edit: I just tried - seems to work fine. Some additional suggestions, though:

  • make the (internal) CSS a separate variable, so one can modify/replace it (e.g. I'd prefer the radios to appear in one row - which can be done with CSS)
  • For testing purposes, the pre-configured menu is great. Though I'd consider to comment it out for the release, so people could include (@require) the script directly. For testing purposes, comment marks are easily removed :-)

Great design, I like it very much! Guess I will steal a bit of code for my GM_config Extender. Feel free to take revenge: Guess the localization system of my script could be of interest for you...

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel