




From a previous suggestion on the Quoting System.
Thead Owner : Psych0-Smil3s,
Category : Suggestions & Feedback,
2 Comment,
37 Read
Viewers:
1 Guest(s)
03-13-2014, 03:20 PM
This was mentioned earlier, this is for the notification system i have seen some request for. This will impliment the notifications to let users know they have been quoted in any particular thread.
Code:
jQuery.noConflict();
jQuery(document).ready(function($)
{
$('body').on({
click: function(event)
{
event.preventDefault();
var popup_id = $(this).attr('id') + '_popup';
$('#' + popup_id).attr('top', $(this).height() + 'px').slideToggle('fast', function() {
var toMarkRead = [];
$('[id^="alert_row_popup_"]').each(function() {
toMarkRead.push($(this).attr('id').substr(16));
});
$.get('xmlhttp.php?action=markRead', {
my_post_key: my_post_key,
toMarkRead: toMarkRead
}, function(data) {
});
});
return false;
}
}, '.myalerts_popup_hook');
$('.myalerts_popup *').on('click', function(event) {
event.stopPropagation();
});
$("body:not('.myalerts_popup:visible')").on('click', function() {
$('.myalerts_popup:visible').hide();
});
$('#getUnreadAlerts').on('click', function(event) {
event.preventDefault();
$.get('xmlhttp.php?action=getNewAlerts', function(data) {
$('#latestAlertsListing').prepend(data);
});
});
$('.deleteAlertButton').on('click', function(event) {
event.preventDefault();
var deleteButton = $(this);
$.getJSON(deleteButton.attr('href'), {accessMethod: 'js'}, function(data) {
if (data.success)
{
deleteButton.parents('tr').get(0).remove();
if (data.template)
{
$('#latestAlertsListing').html(data.template);
}
}
else
{
alert(data.error);
}
});
});
if (typeof myalerts_autorefresh !== 'undefined' && myalerts_autorefresh > 0)
{
window.setInterval(function() {
$.get('xmlhttp.php?action=getNewAlerts', function(data) {
$('#latestAlertsListing').prepend(data);
});
}, myalerts_autorefresh * 1000);
}
if (typeof unreadAlerts !== 'undefined' && unreadAlerts > 0)
{
document.title = document.title + ' (' + unreadAlerts + ')';
}
});
Code:
Event.observe(window, 'load', function() {
Event.observe('unreadAlerts_menu', 'click', function(e) {
Event.stop(e);
var popup_id = e.target.identify() + '_popup';
Effect.toggle(popup_id, 'blind', {
afterFinish: function() {
var toMarkRead = new Array;
$$('[id^="alert_row_popup_"]').each(function(s, index) {
toMarkRead.push(s.readAttribute('id').substr(16));
});
new Ajax.Request('xmlhttp.php?action=markRead',
{
method:'get',
parameters: {
my_post_key: my_post_key,
toMarkRead: Object.toJSON(toMarkRead),
js_type: 'prototype'
},
onSuccess: function() {},
onFailure: function() {}
});
}
});
});
Event.observe('getUnreadAlerts', 'click', function(e) {
Event.stop(e);
new Ajax.Request('xmlhttp.php?action=getNewAlerts',
{
method:'get',
onSuccess: function(transport) {
Element.insert('latestAlertsListing', { 'top': transport.responseText })
},
onFailure: function() {}
});
});
$$('.deleteAlertButton').invoke('observe', 'click', function(e) {
Event.stop(e);
var deleteButton = $(this);
console.log(deleteButton);
new Ajax.Request(deleteButton.readAttribute('href'),
{
method: 'get',
parameters: {accessMethod: 'js'},
onSuccess: function(transport, json) {
var data = transport.responseJSON;
if (data['success'])
{
deleteButton.up('tr').remove();
if (data['template'])
{
$('latestAlertsListing').replace(data['template']);
}
}
else
{
alert(data['error']);
}
}
});
});
if (typeof myalerts_autorefresh !== 'undefined' && myalerts_autorefresh > 0)
{
window.setInterval(function() {
new Ajax.Request('xmlhttp.php?action=getNewAlerts',
{
method:'get',
onSuccess: function(transport) {
Element.insert('latestAlertsListing', { 'top': transport.responseText })
},
onFailure: function() {}
});
}, myalerts_autorefresh * 1000);
}
if (typeof unreadAlerts !== 'undefined' && unreadAlerts > 0)
{
document.title = document.title + ' (' + unreadAlerts + ')';
}
});
03-13-2014, 03:38 PM
The issue with an alerts system, is that it hogs a lot of resources.
Forum Owner
03-13-2014, 04:33 PM
Normally yes, but this is set for an ACP option to define refresh interval, not user based to avoid resource issues. Can also be set to any max notifications, regardless of type, ACP options for new users being activated, not just on reg, but activated, user cp option for notifying any new post or just new posts in your own threads. Cuts down on the resources considerably.