Share:    Facebook Facebook Reddit

Shiny counter changes
#1
Hi everyone,

first off let me just say how great the shiny counter app is, great job!  :D

One thing that bugs me however is that the counter does not remember your chain if you reload or exit the page, which is a bit meh for longer hunts.

Thus, I made a slightly modified version which uses browser cookies to "remember" both your current chain and settings (version, mode, shiny charm, fast music). I used cookies because they make for a very easy (no SQL!) and transparent (to the technologically adept user) method of retaining data.
I uploaded the modified version to a webspace at this address.
The modified files can be accessed as a ZIP file here.

The "pokeradar.php" file is an abridged version without the surrounding pokemonforever.com framework, but not actually modified.
The included diff file illustrates the changes I made to create the version with cookies ("pokeradar.php") (generated with the diff provided by Git Bash).
A side-by-side comparison can be accessed at https://www.diffchecker.com/nr6mwxea
The cookies are set to expire after 1000 days, that should in general suffice. A expiry date had to be specified in order to make browsers actually retain them even after the session ended.
I think it would be neccessary to give some sort of explanation about the use of cookies, as some users might have set their browsers to not allow cookies.
I tested the modifications using a vanilla XAMPP server on my local machine using Chrome, Firefox and Edge.
I also blocked cookies (for localhost) in Firefox, the counter worked just fine without data being preserved when refreshing.

It would be awesome if you could implement these changes!

Best regards,
LtSurgekopf
Reply
#2
Thanks for the input!

Honestly, I planned for something like this at one point but laziness and the fact that no one requested it until now put the idea on the back burner.

That said, I basically just included your changes (thanks for the diffchecker!) into the actual code and ended up having to fix a series of bugs and unexpected outputs but everything should be working fine now!

For everyone else, this basically means that the Pokeradar now saves your current settings when you refresh or close the browser.
I'm the lead developer for the site! (Formerly My Cupcake Money)
[ My Stream | My Pokeradar Thing ]
Let me know if anything comes up~
Reply
#3
Hella Cool.
Follow us on Twitter @_pokemonforever
Learn about us on our Welcome Page
Watch us play games on Twitch.tv
Reply
#4
Hi,

glad you like it!

One thing though: I looked over the new code (cause I was curious what you had to change) and I noticed that you changed the function setCookie(..) to not actually append the calculated expiry date to the cookie.
This is problematic because if you do not include the expiry date using "expires" or "max-age", it is only valid until the end of the browser session. See https://developer.mozilla.org/en-US/docs...g_a_cookie for reference.
I decided on 1000 days because that should be adequate for most cases, but looking over the documentation, it appears that "max-age=Infinity" would also be possible.
Here is a screenshot of one of the cookies in Firefox: https://goo.gl/photos/eukD1Ai6wk7DzZc86

~ Josh
Reply
#5
Actually, I just copy-pasted the code in the diffchecker for set/getcookie. No changes were made there. The diffchecker still shows that the expiration wasn't there and I just didn't catch that.

All my changes had to do with logic for my code to handle being started at any position other than the default because I coded it so lazily not thinking that something like this would come up.

Anyway, thanks for pointing out the difference. Fixed!
I'm the lead developer for the site! (Formerly My Cupcake Money)
[ My Stream | My Pokeradar Thing ]
Let me know if anything comes up~
Reply
#6
Oops, I think I forgot to update the diff when I fixed the expiration...
Glad to see it's fixed now! Smile
Reply


Forum Jump:
POKéMON of the Day

#633 Deino

Recent Threads
Pokemon Infinite Fusion PC
Forum: Other Game Discussion
last post by piersy
Oct 9, 2024, 08:34 AM
[LOOKING FOR] Ponyta in a Heal Ball
Forum: Pokemon Trading, Breeding, & Friend Safari
last post by Cubby Gamer
Jan 8, 2024, 03:08 PM
[FRIEND SAFARI] Dusclops Safari
Forum: Pokemon Trading, Breeding, & Friend Safari
last post by Flinger2004
Oct 12, 2023, 10:14 PM
[NEW MEMBER] im new (and cool)
Forum: Meet and Greet
last post by beebs
Jun 19, 2023, 03:38 PM
[LOOKING FOR] Non American Pikachu
Forum: Pokemon Trading, Breeding, & Friend Safari
last post by trainerkami
Apr 9, 2023, 01:51 AM


Users browsing this thread: 1 Guest(s)