Skip to content

Node.js based forum software built for the modern web

Merge remote-tracking branch 'origin' into notifications

Julian Lamffbafc99c4ae
diff --cc public/src/app.js
index efb08e8fd7,198cef6d51..aa9c940bc9
--- a/public/src/app.js
+++ b/public/src/app.js
@@@ -66,53 -111,62 +111,62 @@@ var socket
// title = bolded title text
// message = alert message content
// timeout default = permanent
- // location : notification_window (default) or content
+ // location : alert_window (default) or content
app.alert = function(params) {
- var div = document.createElement('div'),
- button = document.createElement('button'),
- strong = document.createElement('strong'),
- p = document.createElement('p');
+
var alert_id = 'alert_button_' + ((params.alert_id) ? params.alert_id : new Date().getTime());
- jQuery('#'+alert_id).fadeOut(500, function() {
- this.remove();
- });
-
- p.innerHTML = params.message;
- strong.innerHTML = params.title;
+ var alert = $('#'+alert_id);
- div.className = "alert toaster-alert " + ((params.type=='warning') ? '' : "alert-" + params.type);
-
- div.setAttribute('id', alert_id);
- div.appendChild(button);
- div.appendChild(strong);
- div.appendChild(p);
-
- button.className = 'close';
- button.innerHTML = '×';
- button.onclick = function(ev) {
- div.parentNode.removeChild(div);
+ if(alert.length > 0) {
+ alert.find('strong').html(params.title);
+ alert.find('p').html(params.message);
+ alert.attr('class', "alert toaster-alert " + ((params.type=='warning') ? '' : "alert-" + params.type));
}
+ else {
- if (params.location == null) params.location = 'alert_window';
+ var div = document.createElement('div'),
+ button = document.createElement('button'),
+ strong = document.createElement('strong'),
+ p = document.createElement('p');
- jQuery('#'+params.location).prepend(jQuery(div).fadeIn('100'));
+ p.innerHTML = params.message;
+ strong.innerHTML = params.title;
- if (params.timeout) {
- setTimeout(function() {
- jQuery(div).fadeOut(1000, function() {
- this.remove();
- });
- }, params.timeout)
- }
+ div.className = "alert toaster-alert " + ((params.type=='warning') ? '' : "alert-" + params.type);
+
+ div.setAttribute('id', alert_id);
+ div.appendChild(button);
+ div.appendChild(strong);
+ div.appendChild(p);
+
+ button.className = 'close';
+ button.innerHTML = '×';
+ button.onclick = function(ev) {
+ div.parentNode.removeChild(div);
+ }
- if (params.clickfn) {
- div.onclick = function() {
- params.clickfn();
- jQuery(div).fadeOut(500, function() {
- this.remove();
- });
+ if (params.location == null)
- params.location = 'notification_window';
++ params.location = 'alert_window';
+
+ jQuery('#'+params.location).prepend(jQuery(div).fadeIn('100'));
+
+ if (params.timeout) {
+ setTimeout(function() {
+ jQuery(div).fadeOut(1000, function() {
+ this.remove();
+ });
+ }, params.timeout)
+ }
+
+ if (params.clickfn) {
+ div.onclick = function() {
+ params.clickfn();
+ jQuery(div).fadeOut(500, function() {
+ this.remove();
+ });
+ }
}
}
}
diff --cc src/websockets.js
index 40e574641a,831c0a2639..9d0d50a5a1
--- a/src/websockets.js
+++ b/src/websockets.js
@@@ -7,8 -7,9 +7,10 @@@ var SocketIO = require('socket.io').lis
posts = require('./posts.js'),
utils = require('./utils.js'),
topics = require('./topics.js'),
+ categories = require('./categories.js'),
- notifications = require('./notifications.js');
++ notifications = require('./notifications.js'),
+ threadTools = require('./threadTools.js'),
- postTools = require('./postTools.js'),
- categories = require('./categories.js');
++ postTools = require('./postTools.js');
(function(io) {
var users = {},
@@@ -235,25 -236,9 +237,25 @@@
});
socket.on('api:posts.restore', function(data) {
- posts.restore(uid, data.pid);
+ postTools.restore(uid, data.pid);
});
+ socket.on('api:notifications.get', function(data) {
+ user.notifications.get(uid, function(notifs) {
+ socket.emit('api:notifications.get', notifs);
+ });
+ });
+
+ socket.on('api:notifications.counts', function(data) {
+ user.notifications.counts(uid, function(counts) {
+ socket.emit('api:notifications.counts', counts);
+ });
+ });
+
+ socket.on('api:notifications.mark_read', function(nid) {
+ notifications.mark_read(nid, uid);
+ });
+
socket.on('sendChatMessage', function(data) {
var touid = data.touid;