Location: Asia Pacific, Cyberspace, in the Dark Dystopia
Posts: 19,118
Thanks Given: 2,351
Thanked 3,359 Times in 1,878 Posts
Ravinder,
Please write a PHP function to parse the $color[] array and create the string(2) to append in the badge alert text.
Hint: You need to read a $serialized_badges JSON string (which we will get from the user table and convert it to a PHP array using json_decode() then perhaps a foreach() loop to compare against the current $color[] array.
Or, you can do all this in Javascript by storing the badge[] js array serialized in localstorage, which is how I would do it I think.... No reason to do this in PHP, so I think best to do in Javascript.
Note, I'm jumping on a plane in a few hours, so I don't have time to check this properly, but I'm thinking:
Please take a look and let me know what you think Ravinder!
Thanks
PS: I have not debugged that code above yet and realize that we need to add logic to not query the DB after we reset; because we already have the value (1) so no reason to do the extra query, etc.
Hello Neo,
Thank you for writing this one(I apologies that I am not at all getting time to write anything as of now). I have gone through code and it looks great, for my and everyone's understanding I have added explanation too in code(you could let me know if I missed or wrongly mentioned anything here).
Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
Ravinder,
Please write a PHP function to parse the $color[] array and create the string(2) to append in the badge alert text.
Hint: You need to read a $serialized_badges JSON string (which we will get from the user table and convert it to a PHP array using json_decode() then perhaps a foreach() loop to compare against the current $color[] array.
Or, you can do all this in Javascript by storing the badge[] js array serialized in localstorage, which is how I would do it I think.... No reason to do this in PHP, so I think best to do in Javascript.
Sorry Neo I didn't get it if you could give me little more scenario like sample input and expected output then I will try my BEST to write it. Sorry I am that good like you in coding to be honest.
Location: Asia Pacific, Cyberspace, in the Dark Dystopia
Posts: 19,118
Thanks Given: 2,351
Thanked 3,359 Times in 1,878 Posts
Hi Ravinder,
It's OK. Thanks for the great ideas on the badging system.
No reason to worry about coding, as I know you are busy working 12 to 13 hours a day on your IT job.
I will code the "days active in sequence" badge when I am back at my desk after the 8th of Jan and will prototype a simple "new badge issued" alert based on a hash of the JSON string-ified badges afterwards.
You have already done a lot and I can easily take it from here and finish the prototype badging system and leave a few badges "in reserve" for the future.
Take care and keep sharing your good ideas for the forums!
Location: Asia Pacific, Cyberspace, in the Dark Dystopia
Posts: 19,118
Thanks Given: 2,351
Thanked 3,359 Times in 1,878 Posts
Update:
While on vacation, had some free time and have written the core code to show a Bootstrap alert when a member badge changes. Also, have the basic code in place to determine exactly which badge changes, so that can be added to the message; but have not written the function to change the array keys to text.
Currently testing via PHP logging. Seems to work fine.
When I am back at my desk, will write a function to change array keys to user friendly text and continue testing.
Location: Asia Pacific, Cyberspace, in the Dark Dystopia
Posts: 19,118
Thanks Given: 2,351
Thanked 3,359 Times in 1,878 Posts
Testing, it seem the comparing cryptographic hashes of the badges array, serialized as a JSON file, do not provide as much consistency as comparing an array stored in the DB with a recently generated array using the PHP function array_diff_assoc():
So, tomorrow I will refine the alert code to also use array_diff_assoc() .
Currently am comparing a generated hash with a stored hash as a cookie. This works well, but it could be even better, so I'm going to do both (I think), compare the hashes and also compare the badge arrays. Still testing ...
Also, I'm going to stop posting in the Underground and move this thread to the main forums.
I have moved the bug badge out of reserve and into the main stream. Basically, I will assign a color level like the others, based on who has made a good actionable bug report for UNIX.COM. "Good" means screenshots, links, and even details from web dev tools our the HTML source code. So far,... (0 Replies)
Dear All,
Here is the current status of the badging system:
The Beta 1 phase of the new badging system is close to completion.
42 prototype badges have been "allocated"
6 prototype badge slots are held in reserve
The "alert you have new badges" prototype is running and is currently... (4 Replies)
Today I mapped out the new badging system using FA icons, Beta 1 in no particular order except a 6 x 8 grid:
https://www.unix.com/members/1-albums215-picture991.png
The prototype HTML code for this layout:
<style>
.fa-badge-grid {
font-size: 1.5em;
}
.row {
... (38 Replies)