Post by P̌̓aͧś̀t̀u͒le͆o͂2̀3̃̓ on May 2, 2016 4:53:53 GMT -8
Download: Shoutbox Comments 1-0-3.pbp (4.8 KB)
Library Link: www.proboards.com/library/plugins/item/1305
New: Show Previous Comments / Collapsed
Description: This plugin uses a super forum key to store comments made on a shoutbox post. This allows for direct replies to shouts without having it lost among other shouts. This also has a bump feature to automatically recognize the newest comment instead of the original shout's timestamp. This bump feature supports both bottom and top orientations and is configured automatically so newest comments will appear on the bottom/top along with the original shout. You will have to refresh your page to see any new comments-(This is a limitation of Proboards)
Comments do not parse HTML or BBCode at this time.
I could add support for certain BBCode upon request.
Prerequisite: Yootil
Features:
Custom Dialog Text
Bumps
Comment, Edit, Delete
Guest Comment Option
Edit/Delete Permission Selection
Notification Banner
Multiple Comments Load Collapsed
Key Permissions
Removes Old Comments Automatically
Secure from HTML/JS injection
Should never reach max key storage-Note: It is possible but will fix itself in that event
Background and Text Color Change
Extension:
Supported By Interests Notification Center to add notifications on comments (version 2-3-4)
Future Additions:
-shows previous/all comments to a shout, by default / optional
-show the Comment/Edit "buttons/links" by default, instead of having to hover over them
-change the comments background color/borderColor/textColor
-Change Un-Collapse to Image of arrow or message bubble/optional collapse again
-Default Collapsed/Uncollapsed
-Remove Yootil Support
Preview:
Troubleshooting:
Use class detailsHelper for themes with trouble getting the comment button to appear.
Author's Notes:
Library Link: www.proboards.com/library/plugins/item/1305
New: Show Previous Comments / Collapsed
Description: This plugin uses a super forum key to store comments made on a shoutbox post. This allows for direct replies to shouts without having it lost among other shouts. This also has a bump feature to automatically recognize the newest comment instead of the original shout's timestamp. This bump feature supports both bottom and top orientations and is configured automatically so newest comments will appear on the bottom/top along with the original shout. You will have to refresh your page to see any new comments-(This is a limitation of Proboards)
Comments do not parse HTML or BBCode at this time.
I could add support for certain BBCode upon request.
Prerequisite: Yootil
Features:
Custom Dialog Text
Bumps
Comment, Edit, Delete
Guest Comment Option
Edit/Delete Permission Selection
Notification Banner
Multiple Comments Load Collapsed
Key Permissions
Removes Old Comments Automatically
Secure from HTML/JS injection
Should never reach max key storage-Note: It is possible but will fix itself in that event
Background and Text Color Change
Extension:
Supported By Interests Notification Center to add notifications on comments (version 2-3-4)
Future Additions:
-shows previous/all comments to a shout, by default / optional
-show the Comment/Edit "buttons/links" by default, instead of having to hover over them
-change the comments background color/borderColor/textColor
-Change Un-Collapse to Image of arrow or message bubble/optional collapse again
-Default Collapsed/Uncollapsed
-Remove Yootil Support
Preview:
Troubleshooting:
Use class detailsHelper for themes with trouble getting the comment button to appear.
Author's Notes:
This plugin took over 20 hours to complete. It's really hard to track time over a week. I tried several methods to load the key data without having to refresh the page with no luck. I created a feature request for a shoutbox key because of it. I have become very accustomed to Proboards inner-workings however I didn't originally anticipate that copying elements of the theme would corrupt the js used to run the shoutbox. Copying any class name, adding div's, and adding an element after the last shout break the javascript used to run the shoutbox. So I had to make a copy of each css class and give it a new name for my elements. I also had to bind to the shoutbox_updated and shoutbox_shouted events of yootil to re-add the comments and buttons. This covers refreshing, receiving a shout, and making a shout. Sadly there was no event for removing a shoutbox shout. So I tapped into the global ajax complete function and execute additional code when /shoutbox/remove is found in settings. I also had to escape certain html characters such as < and > to prevent malicious attacks. Since forum super keys are high traffic keys, it's never safe to use set() to assign a value. So I opted for the only solution, push/pop/shift/unshift. This means my main data type had to be array. Of course every plugin needs to design their own data structure so I chose an object to save only required data about each shout. I decided to save the shout id (which is found as a class), the user name for viewing, the user id for edit and remove reasons, the shout text, and the timestamp. I originally was thinking about allowing comments on comments but there were a few drawbacks to this idea. I would have had to update all of the sub-numbers whenever a shout was deleted, save extra data, and figure out a new way to display it without it pushing right with margins (Because it would get real squished). I used the pb dialogs for a color and look that would match each forum theme individually and automatically. Whenever I'm dealing with timestamps I must keep a running timer so that when a user comments it won't be based on when the page was loaded, when the page was inactive, or by the users computer time (This avoids timezone differences and the ability to falsify days or years). Currently the limitation for chrome and firefox for an interval is 4 milliseconds. However whenever a page is inactive, they only allow an interval of 1000 milliseconds (ie 1 second). So my timer must always be 1000 milliseconds or longer. This keeps track in a global variable adding to the initial page load found in the pb.data('serverDate') (Which is from the website server directly). Originally I was not aware of any id's attached to shouts so I planned on adding the user's username (Not Display Name) to their message, getting the charCode (numerical representation from the keyboard) of each letter and adding it together. This would be the equivalent of a unique id that would not become duplicated and would also remain the same (Granted no edits made to the shout). You always add key permissions to a plugins user-interface to change from the default key permissions of read/write staff only. To determine the orientation of bottom/top for newest shouts I take the first and last shouts and compare the timestamps. I had to add mouseenter and mouseleave functions to hide each of my custom button controls to mimic the Ban and edit buttons. Originally I had used the class names had it not broke the shoutbox. This request was special in that it had to support guests fairly. I thought about adding a temporary id to guests via cookies that would allow them to edit/delete their posts temporarily. This idea was scratched due to security and overall necessity. It could be added in a future release. There is an easy way to determine if a user is guest. if(!pb.data('user').id) that means they are a guest. Their id is 0 and their name is Guest. I decided to mimic the text counter with a textarea keyup function to update the count and a maxlength attribute to the textarea to prevent additional typing. I added several (cheap) alerts to prevent missing name/text in crucial areas. My initial key push detects for error.code 64 for invalid data type. This means I pushed to a key that has no data. Then it initializes with a one-time key set and re-pushes the information. I added a busy flag for when a user tries to spam comments without the background process being caught up. The newer comments get unshifted to the beginning whereas the older comments will get pop'd off the end. My removal checks the oldest shout id and looks for 5 ids older than that working from the keys end backwards until it no longer finds comments that are un-needed. Then it does a one time num_items pop that ditches that useless data. The 5 id's older is based on a concept of shouts never deleting. I studied the shoutbox admin panel and realized that shouts were viewable since forum creation. So I studied that on page load, you will see around 25 shouts. The older one's won't be loaded UNLESS someone deletes a newer shout. Which means older shouts can come back into play. So I didn't want to delete those comments. I also detected for error.code 16 for a full key. When that happens you can't add a comment, but it runs the removal and when another shout falls off you should be good. Another observation is that older shouts aren't knocked out of view for users who have them loaded already. So I took that into consideration with my plugin. The complicated part about removing and editing a shout comment is that you must remove all of the previous comments in the array until you get to the index of the item and then put all of them back (possibly without the one you wanted removed). This makes a simple one step set into a three step process and that takes up valuable time. Sometimes a guest post or edit would take more time to update the display than it took for the event to fire. Meaning the shoutbox wouldn't have my comments added in. So I added in a safety check that would make a re-do or bascially check again after 500 milliseconds had passed. I realized that the shoutbox_updated event fires repeatedly in the course of a minute even when no data is added. So I compare the keys previous length with it's new length (to determine if it's running because something had been added or taken away) with another check to determine if there are any comments already in the shoutbox. If it all checks out I do nothing. Otherwise I might just need to re-add the controls to the one added shoutbox shout, or add everything. The bump feature was a crazy concept. I couldn't copy the posts, sort them, and add them back without losing some of the built in handlers attached. So I decided to store the last timestamp of each, sort that, and then append the post to the shoutbox area (effectively only moving the shout to the top), but in order of the comments timestamps (if commented on) and not the original shouts timestamp. Note that it also takes a lot of time to set up previews, test each function under every circumstance, and submit it to the library. Not to mention creating a support thread and keeping up with everyone's problems and requests. And I can usually find something I overlooked or tested for a number when it was saved as a number in text form. Creating the User Interface in manage is also time consuming if I haven't mentioned that. Then only adding certain things if the main admin selects yes, no, maybe, or even selecting nothing at all has to be accounted for. I'm sure there are plenty of other things I had to consider when developing this plugin such as what the Original Request was looking for and what I could add as a bonus to make it look like an innate feature of proboards and not something pasted as an extra. I want my plugins to be integrated, and sometimes that means using the same images and functions that Proboards uses to operate. Kudos to Oreo King for the request. If you are still reading this you probably have something more important you could be doing. All Your Base Are Belong To Us.