Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make suggest questions mode persistent (issue #88) #89

Merged
merged 8 commits into from
Jun 26, 2014

Conversation

studgeek
Copy link
Contributor

First rough draft at making suggestions persistent (suggestion #88). Its rough and needs cleanup, but shows the idea.

It makes the following changes:

  • Enabling suggest mode can be done with localStorage. So localStorage.setItem("devMode", true); enables and localStorage.removeItem("devMode"); disables.
  • Suggestions are stored in localStorage. So they persist across refreshes and sessions.
  • Persisted suggestions can be cleared with Clear Suggestions button.
  • Suggest Question is shown for all questions (when enabled) to make it easy to suggest questions for new categories.
  • The list of existing categories for each question is shown.
  • Gets rid of all the dialogs, including the verification dialogs and the category dialogs. The user is expected to read wiki and know what they are doing.
  • Categories are no longer shown in the suggested text. Instead the user is asked to group by them in their email. With an update in the wiki page I think this will work better. The grouping by category is very simple now in the new style.
  • Includes a link back to wiki to explain how to use it.

Work still to do:

  • Suggest questions is not shown when moving to a new page. This is because the extension currently doesn't catch page transitions (it only loads on a new page). The workaround is to simply refresh the page. Since the state is persisted they are all there after refreshing.
  • Style cleanup (including introducing constants and some refactoring)

@studgeek
Copy link
Contributor Author

I added a couple more commits:
The main one Updates the answer parsing code to handle the new question style (that has no their_answer). Fixes answerText, score, weight.
I also refactored some duplicated code.

@studgeek
Copy link
Contributor Author

One thing that needs to be fixed with my code is I am using unscoped keys for localStorage. I had not realized it was shared with page for content scripts. It probably needs to be prefixed.

@benjaffe
Copy link
Owner

Yes, all stored data should be properties on localStorage.okcp. I also use,
.okcpRecentProfiles, or .okcpSettings (which I actually haven't been using)

On Tue, Jun 17, 2014 at 5:46 PM, David Rees notifications@github.com
wrote:

One thing that needs to be fixed with my code is I am using unscoped keys
for localStorage. I had not realized it was shared with page for content
scripts. It probably needs to be prefixed.


Reply to this email directly or view it on GitHub
#89 (comment)
.

Ben Jaffe • Developer, Instructor, GeekSpeak, KUSP
510.545.2365 • benjaffe.me • Github https://github.com/benjaffe/

LinkedIn https://www.linkedin.com/in/benjaffe

@benjaffe
Copy link
Owner

@studgeek , for adding keys, check out the util I wrote for it -- https://github.com/benjaffe/chrome-okc-plugin/blob/master/plugin/storage.js

_OKCP.storage('messages') // getter
_OKCP.storage('messages', myVar) // setter

@studgeek
Copy link
Contributor Author

Agreed on everything, good suggestions (and consistency is always important). Will also move it to using its own on/off flag rather than devMode as you suggested elsewhere. I will post comment once I have applied the suggested changes.

@benjaffe
Copy link
Owner

Sweet, thanks David -- you rock!

On Fri, Jun 20, 2014 at 7:05 PM, David Rees notifications@github.com
wrote:

Agreed on everything, good suggestions (and consistency is always
important). Will also move it to using its own on/off flag rather than
devMode as you suggested elsewhere. I will post comment once I have applied
the suggested changes.


Reply to this email directly or view it on GitHub
#89 (comment)
.

Ben Jaffe • Developer, Instructor, GeekSpeak, KUSP
510.545.2365 • benjaffe.me • Github https://github.com/benjaffe/

LinkedIn https://www.linkedin.com/in/benjaffe

…e. Enable/disable by setting to "true" in console using localStorage.setItem("okcpDevMode","true")
…ds cleanup, but shows the idea.

It makes the following changes:
- Suggestions are stored in localStorage. So they persist across refreshes and sessions.
- Persisted suggestions can be cleared with Clear Suggestions button.
- Suggest Question is shown for all questions (when enabled) to make it easy to suggest questions for new categories.
- The list of existing categories for each question is shown.
- Gets rid of all the dialogs, including the verification dialogs and the category dialogs. The user is expected to read wiki and know what they are doing.
- Categories are no longer shown in the suggested text. Instead the user is asked to group by them in their email. With an update in the wiki page I think this will work better. The grouping by category is very simple now in the new style.
- Includes a link back to wiki to explain how to use it.

Work still to do:
- Suggest questions is not shown when moving to a new page. This is because the extension currently doesn't catch page transitions (it only loads on a new page). The workaround is to simply refresh the page. Since the state is persisted they are all there after refreshing.
- Style cleanup (including introducing constants and some refactoring)
…ake the JSOB object

Uses JSON. stringify space argument as suggested by @benjaffe
… no their answer). Fixes answerText, score, weight.
…tMode to enable/disable by setting to "true" in console using localStorage.setItem("okcpSuggestMode","true")

Instead of using new-feature CSS, just don't run the suggest question logic at all when not in suggest mode (saves cycles).
@studgeek
Copy link
Contributor Author

Ok, I think I have all the suggested changes in there. Plus a few more tweaks. FYI, I rebased it to clean up commit history a bit.

benjaffe added a commit that referenced this pull request Jun 26, 2014
Make suggest questions mode persistent (issue #88)
@benjaffe benjaffe merged commit 19fa16a into benjaffe:master Jun 26, 2014
@benjaffe
Copy link
Owner

@studgeek , Can you update the wiki to describe how users suggest questions? I already have a page you can modify. Also, I'm having trouble getting the buttons to show up, even though;

localStorage.okcpDevMode === "true" //true

I should see the buttons on the questions pages right? I'm not seeing them either on other users' questions pages, or my own. Any ideas?

@studgeek
Copy link
Contributor Author

studgeek commented Aug 4, 2014

Sorry I didn't see your comment until now.

I have updated the wiki with the updated instructions.

And suggest mode is working for me in the master branch. Once I run localStorage.setItem("okcpSuggestMode", true) I see the Suggest Question buttons:
screen region 2014-08-03 at 17 47 05
And the JSON at the bottom
screen region 2014-08-03 at 17 47 30

@studgeek
Copy link
Contributor Author

studgeek commented Aug 4, 2014

Actually, I found a small bug. The Clear Questions button was not visible.

@studgeek
Copy link
Contributor Author

studgeek commented Aug 4, 2014

Pull request #104 makes the Clear Questions button visible. I updated the wiki with that info.
clear questions

@benjaffe
Copy link
Owner

benjaffe commented Aug 4, 2014

Cool! Yeah, I was just missing localStorage.okcpSuggestQuestions . Awesome, thank you! It'll be published within an hour.

@studgeek
Copy link
Contributor Author

The original suggestQuestions code generates a "weight" array, but I don't see it used in the questions files. Is weight no longer used and should I take it out of suggestQuestions?

@benjaffe
Copy link
Owner

It's definitely used for some questions. I didn't integrate it fully in
suggest questions because I figured it'd be confusing to most users. I was
manually adding the weight when adding the question into the plugin. Sorry
for the quick response... On mobile and on the go!

Sent from my phone, so excuse the brevity.
On Jan 18, 2015 1:25 PM, "David Rees" notifications@github.com wrote:

The original suggestQuestions code generates a "weight" array, but I don't
see it used in the questions files. Is weight no longer used and should I
take it out of suggestQuestions?


Reply to this email directly or view it on GitHub
#89 (comment)
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants