Shiny counter changes - Printable Version +- Pokemon Forever (http://pokemonforever.com) +-- Forum: Getting Started (http://pokemonforever.com/Forum-Getting-Started) +--- Forum: Announcements (http://pokemonforever.com/Forum-Announcements) +--- Thread: Shiny counter changes (/Thread-Shiny-counter-changes) |
Shiny counter changes - LtSurgekopf - Sep 26, 2015 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 RE: Shiny counter changes - Agro - Sep 27, 2015 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. RE: Shiny counter changes - Justin - Sep 28, 2015 Hella Cool. RE: Shiny counter changes - LtSurgekopf - Sep 29, 2015 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/Web/API/Document/cookie#Writing_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 RE: Shiny counter changes - Agro - Sep 30, 2015 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! RE: Shiny counter changes - LtSurgekopf - Oct 1, 2015 Oops, I think I forgot to update the diff when I fixed the expiration... Glad to see it's fixed now! |