fedarko / MetagenomeScope

Hierarchical scaffold/assembly graph web visualization tool. As of August 9, 2017, the official repository for this has moved to MarBL! Use that repository instead :)
http://github.com/marbl/MetagenomeScope
GNU General Public License v3.0
0 stars 0 forks source link

Default color settings aren't reset when user closes page tab #263

Closed fedarko closed 7 years ago

fedarko commented 7 years ago

This should be handled in doThingsBeforeUnload(), but it doesn't seem to be at present.

fedarko commented 7 years ago

Looks like this is actually a bug in Chromium? (Iceweasel seems to handle it correctly.)

Looking at the problem from another perspective -- it looks like autocomplete="off" is a valid argument for <input> tags. Perhaps using that instead of calling resetColorSettings() in doThingsBeforeUnload() would be a better alternative, since autocomplete="off" seems to work even in the case of ctrl-W, etc.

fedarko commented 7 years ago

Nope, turns out "autocomplete=off" didn't work in Iceweasel for some reason?

The whole point of automating the default color settings string generation was to save time, so I don't really see the benefit if maintaining that solution requires me to spend a lot of time on this sort of minutia. So... I think I'm just going to go back to the old way of getting around this by using a manually declared default color string in xdot2cy.js.

fedarko commented 7 years ago

Some context about this, for reference --

Adding in a "reset to default" button for the color settings necessitated some way of storing the default settings so they could be restored. The original way I did this was by manually keeping a string of the default settings (declared near the top of xdot2cy.js).

However, updating the default color settings (or adding additional colors) necessitated making two changes (once in HTML and once in JS). That got to be a little inconvenient, so I switched to having the JS code record the default color settings on page load, which alleviated the need for manually keeping a default string ready. The problem with this was that browsers tend to save the previous values entered in the input fields in a page -- and that gives rise to the issue of, say, changing the colors, navigating away from the page, navigating back to the page, and then now the previously modified color values are there -- and the code thinks the modified values are the defaults, so "reset to default" doesn't work properly anymore.

I tried a number of ways to circumvent that problem (including binding an invocation of resetColorSettings() to the beforeunload window event, and adding the autocomplete="off" property to color input fields), but they still failed in certain cases (the binding thing didn't work when you closed the tab directly using Ctrl-W and reopened it using ctrl-shift-T in Chromium 57.0.2987.98, and the autocomplete thing seemed not to work in Iceweasel 38.7.1).

So I just settled on going back to the previous method of hardcoding the defaults as a string. I've added comments to the code that detail the steps to update this string, so it shouldn't take more than a minute or two to do that in the future -- definitely not a huge deal, and I think it'll probably save me some time to do that instead of devoting a lot of time to worrying about the issues associated with automating it.