inherit
96289
0
May 17, 2020 9:37:00 GMT -8
elli
1,822
January 2007
ebbymac
|
Post by elli on Jul 7, 2019 12:20:53 GMT -8
Follow up to this thread. I've created a plugin that hides a Cbox behind a dialog, which is triggered by a button. When the dialog is closed and a new message is received, a notification appears over the button. localStorage then saves the notification state so that it persists when navigating the rest of the forum or refreshing the page. Preview (button is in the bottom right): ellitest.proboards.com/To see the notification working: duplicate your browser tab, open the dialog from one tab, and send a message. You should see a red notification appear over the trigger button in the other tab. (Console logs will also show this.) I would love feedback on this plugin! It's editable. Thoughts on the JavaScript, how it can be improved, whether any bugs exist, etc. Feel free to use my test Cbox in the plugin settings: www2.cbox.ws/box/?boxid=2401891&boxtag=k7kCPgelli-mccale/pbp-cbox-notificationsImprovements that can be made: - Add more customization options to the trigger button
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Jul 9, 2019 3:33:15 GMT -8
Had a little play with it and read through the source. - Works as expected, no issues that I noticed from limited testing. - Source is clean and easy to read. Only suggestion would be to check the orign property exists before doing a match on it. Looks to be something you just overlooked, as I see you do test for the data property prior to reaching that point. Nicely done
|
|
inherit
96289
0
May 17, 2020 9:37:00 GMT -8
elli
1,822
January 2007
ebbymac
|
Post by elli on Jul 9, 2019 10:57:58 GMT -8
Peter Thank you! So something like this? if (!e.origin || !e.origin.match(/cbox.ws$/)) Is this common with the postMessage API? I've never used it before this.
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Jul 9, 2019 13:49:55 GMT -8
elliYes, exactly like that. It's a minor thing really, but considering it's data that comes from a 3rd party site, then you should always expect the worst case scenario. By checking the property, you avoid a potential error. It's common on data that you have no control over. So in this case, you have no control over what data is being fed to the dispatched event ( message), so it should be validated. Chances of there being an issue is likely none, but it's good practice anyway, even if it does seem a little overkill.
|
|
inherit
96289
0
May 17, 2020 9:37:00 GMT -8
elli
1,822
January 2007
ebbymac
|
Post by elli on Jul 9, 2019 18:33:42 GMT -8
Peter That makes sense, I will get that added.
|
|
inherit
96289
0
May 17, 2020 9:37:00 GMT -8
elli
1,822
January 2007
ebbymac
|
Post by elli on Jul 13, 2019 15:00:51 GMT -8
I've updated this to beta, which includes customization options for the button and notification. It also now checks origin before match and builds the button and notification dynamically.
Possible improvements: - Allow custom placement of the button - Allow resizing of dialog window (as an option)
|
|
inherit
96289
0
May 17, 2020 9:37:00 GMT -8
elli
1,822
January 2007
ebbymac
|
Post by elli on Jul 31, 2019 14:32:52 GMT -8
|
|