unitedstates / glossary

A glossary for the United States.
Creative Commons Zero v1.0 Universal
42 stars 13 forks source link

General purpose front-end integration JavaScript library #21

Open konklone opened 10 years ago

konklone commented 10 years ago

I added some super basic integration into Scout, using a JS-driven approach here:

https://github.com/sunlightlabs/scout/blob/master/subscriptions/views/federal_bills/_show.erb#L168

This is what is highlighting "Cloture" all over S. Res. 15.

It needs optimization to work for more than a handful of terms (mainly, it needs to be turned into a single regex, rather than passing over the nodes with a regex for every term), but it does handle the hard part of find/replacing text with nodes, in a DOM where text is nested in arbitrary nodes.

Optimizing and generalizing this for easy client-side integration of the glossary would be awesome.

waldoj commented 10 years ago

I learned a UI lesson about definitions with The State Decoded, which I'll pass along here in case you might regard it as useful.

Initially I highlighted defined terms quite prominently, and feedback about that fell into three different categories: 1. This is great. 2. This is incredibly annoying. 3. This is useful, but it makes it very distracting to scan the text, because my eye is drawn only to the defined terms. With experimentation, I found that using a very low-key indicator (a faint, dotted underline), people could either ignore them or seek them out, depending on what they wanted, while nobody found that those indicators distracted them from reading.

JM2C, YMMV, etc., etc.

konklone commented 10 years ago

Yeah, faint was my first instinct and implementation, then people said they could barely see it -- but of course those people were coworkers, not users. =) This is good feedback, I'll make it faint again.

waldoj commented 10 years ago

It seemed to me to be like the Pepsi Challenge—people just checking it out real quick thought the bold definitions were great, but people actually engaged in reading a lot of text for a real purpose often found it frustrating.

gregelin commented 10 years ago

It would be VERY slick if after you moused over a term the highlighting for THAT term became very subtle. In other words, once you've read a definition presumably you do not need to keep reading it.

It is nice to see the definitions short and written to be read while mousing over. This speaks well for value of public domain "mouse-over glossaries" vs traditional glossary lists. Its a good practice.

You know...we should connect mouse-over glossaries with the plain language act and movement http://www.plainlanguage.gov/

Greg

On Wed, Oct 9, 2013 at 9:15 PM, Waldo Jaquith notifications@github.comwrote:

It seemed to me to be like the Pepsi Challengehttps://en.wikipedia.org/wiki/Pepsi_Challenge#Criticism—people just checking it out real quick thought the bold definitions were great, but people actually engaged in reading a lot of text for a real purpose often found it frustrating.

— Reply to this email directly or view it on GitHubhttps://github.com/unitedstates/glossary/issues/21#issuecomment-26022394 .

waldoj commented 10 years ago

It would be VERY slick if after you moused over a term the highlighting for THAT term became very subtle. In other words, once you've read a definition presumably you do not need to keep reading it.

:+1:

I'd want to test this out, to see if it works as well as I think it would, but at first blush I think this is a great idea. I wonder about persistence—if the reduced-strength highlighting resets for each page view, each session, or never resets for that user. I suspect one would want to use client-side storage to save the list of viewed definitions.

konklone commented 10 years ago

It'd probably need to be client-side storage, which could be packaged in a JS library. It does mean it'd reset itself every time they switched browsers or cleared their cache/cookies/etc, so I would still make the default color undistracting, but making it even subtle-r upon seeing it seems like all upside.

gregelin commented 10 years ago

The client-side storage of browsers and powerful HTML5 and ajax means there is the possibility of essentially of building follow-the-user functionality into the use of the Glossary (or statedecoded). After all, Hypothes.is was at the meeting with us and they are pursuing web page annotations.

I'm imagining popping up a little control that may even let me control certain things between visits.

It would make sense that I could as user create my own set of notes and expertise level as I view legislation at Federal, State, Local and other jurisdictions. If Glossaries were common, than I could have my own interaction with glossary that was recognized and consistent across different visits and different sites.

Maybe there is an easy way for all of that to be done via local storage (and give me as user control over it). There's certainly a way to store in the cloud and log into my annotations as I moved across sites.

My guess is that Mozilla would be interested in support this idea. It is a kind of reverse cookie, in which I as the user, native to the browser, have the ability select a profile and decisively store data in that profile that I allow sites to see by default or by white list. It makes sense for this to be a specification and API. Maybe it already is and I just do not know it?

konklone commented 10 years ago

::brain expands::

I have no idea whether you can use local storage to create bins that any website can use, or if they have to be locked per-domain, but there's clearly a lot of fun to be had here. I'm gonna focus on what's in front of me for now, but a separate branch or repo for front-end experimentation is welcome.

waldoj commented 10 years ago

Apparently this is a thing.

gregelin commented 10 years ago

I like it.

Maybe there is a way to do something like gravatar or extend gravatar?

On Thu, Oct 10, 2013 at 1:33 PM, Waldo Jaquith notifications@github.comwrote:

Apparently this is a thinghttp://www.nczonline.net/blog/2010/09/07/learning-from-xauth-cross-domain-localstorage/ .

— Reply to this email directly or view it on GitHubhttps://github.com/unitedstates/glossary/issues/21#issuecomment-26074065 .

konklone commented 10 years ago

I like the model! Looks like the xauth example there is a long-dead project, unfortunately. But with server intervention, anything is possible.