AstroCB/Stack-Exchange-Editor-Toolkit

I'm trying to understand what the heck is going on with the rowNum variable

Closed this issue · 5 comments

I've been working with this code for hours, but haven't got it working yet (didn't work for me by default), and most of what I've been doing is simplifying / improving readability so I can prepare to work with it further, but I'm stuck at the line:

var box = boxes[rowNum - 1].value;

I don't understand what boxes[-1] does where boxes is the text area and rowNum is something you seem to use at the top of the script involved in the placement of the button.

Could you add explanations in comments for this stuff?

I'd like to contribute, but I'm confused as to what's going on there with the things I mentioned.

It's a bit odd (mostly due to the way that Stack Exchange deals with these toolbar buttons), but I'll try to add in some explanation there.

I should be able to take this out: it's legacy code from when I started writing this and was a feeble attempt to make this work for multiple edits at once (that is, you could go through a question on a site where you have editing privileges and edit multiple answers and the button would show up on each one), but there's a separate issue open for that now.

Ok, well multi-question support is essential for those with the privileges, but I think we can package that functionality better.

I have taken it out, along with alerts for those without local storage. I was just confused with what was going on. I understand now that you explained the multiple-question editing scenario.

Two things:

  1. I don't have those kind of editing privileges, so perhaps you can post an example testing file including all of the relevant HTML from a page with multiple editing boxes.

  2. My version right now utilizes JQuery on account of it seriously simplifying the script with the use of .after() to place the button, and it's also nice to shorten those selectors. If you prefer, you can deny my pull request when I submit that and I'll supplement the raw JS equivalent. I think JQuery is OK in cases where the site already has it loaded to be used.

I've tested it on sites without editing privileges, and it should work (but it should give you a warning once: if your browser doesn't support localStorage, then it might not work, which might explain it).

small update to my previous comment regarding that.