New forum post reminder tools

Source: Internet
Author: User
Go directly to the topic and use the real-time reminder tool for new posts in the PHP + HTML5 Development Forum. Look at the development idea: In order to ensure that the browser can receive a message notification at a minimum, we need to use the HTML5 Notifications feature. Read: Notifications desktop reminder www.1990c.com? The following section takes the admin5 Forum task area as an example:

Go directly to the topic and use the real-time reminder tool for new posts in the PHP + HTML5 Development Forum. Look at the development of ideas: In order to ensure that the browser can receive a message to minimize the need to use HTML5 specifications features, recommended read: Specifications desktop reminder http://www.1990c.com /? Under p = 833, a forum in the task area of the admin5 forum is monitored as an example:



Go directly to the topic and use the real-time reminder tool for new posts in the PHP + HTML5 Development Forum.

Let's look at the development ideas:

To minimize the number of Notifications that the browser can receive, you need to use the compliance feature of html5. For more information, see:

Notifications desktop reminder
Http://www.1990c.com /? P = 833


The following uses a forum in the task area of the admin5 Forum as an example:

 New post reminder tool // request desktop notification permission function init () {if (window. webkitNotifications) {window. webkitNotifications. requestPermission () ;}// Message notification function running y (str) {var icon = "logo.png "; // icon path var title = "New post reminder (" + time + "seconds later)"; // Message title var body = str; // message content var popup = window. webkitNotifications. createNotification (icon, title, body); popup. show (); // Display message} // refresh the page function refresh () {document. location. reload ();}
 (. *) <\/A>/', $ str, $ titleData); $ _ SESSION ['title'] = $ titleData [1]; // capture the post title and save it to the SESSION post array echo "setTimeout ('refresh () ', $ sleep )"; // refresh page} else {// do not capture date_default_timezone_set ('prc') for the first time; $ now = mktime (); // calculate the current time $ str = file_get_contents ($ url ); preg_match_all ('/onclick = \ "atarget \ (this \) \" class = \ "xst \"> (. *) <\/a>/', $ str, $ title); // capture the post title preg_match_all ('/(. *) <\/span> <\/em>/', $ str, $ time); // capture the posting time foreach ($ ti Tle [1] as $ k => $ v) {if (! In_array ($ v, $ _ SESSION ['title']) {// determine whether it is a new post if ($ now-strtotime ($ time [2] [$ k]) <300) {// determine whether a new post is posted within 5 minutes?>
 Notify ("
 ");
 

The Code has been simplified for ease of reading. You can modify the code as needed. In addition, using Ajax is also a good method.

Original article address: this is a reminder tool for new forum posts. Thank you for sharing it with me.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.