nodebb-plugin-shoutbox
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -72,5 +72,5 @@ var async = require('async'), | ||
content: '<script> \ | ||
ajaxify.initialLoad = true; \ | ||
templates.ready(function(){ajaxify.go("shoutbox", null, true);}); \ | ||
</script>' | ||
ajaxify.initialLoad = true; \ | ||
templates.ready(function(){ajaxify.go("shoutbox", null, true);}); \ | ||
</script>' | ||
}); | ||
@@ -99,3 +99,3 @@ } | ||
return scripts.concat([ | ||
'plugins/nodebb-plugin-shoutbox/js/main.js' | ||
'plugins/shoutbox/js/main.js' | ||
]); | ||
@@ -146,8 +146,12 @@ } | ||
} | ||
Shoutbox.backend.getShouts(start, end, function(err, messages) { | ||
if (err) | ||
return callback(null, []); | ||
if (socket.uid) { | ||
Shoutbox.backend.getShouts(start, end, function(err, messages) { | ||
if (err) | ||
return callback(null, []); | ||
callback(null, messages); | ||
}); | ||
callback(null, messages); | ||
}); | ||
} else { | ||
callback(null, []); | ||
} | ||
}, | ||
@@ -247,7 +251,2 @@ "send": function(socket, data, callback) { | ||
}, | ||
"getPartial": function(socket, data, callback) { | ||
fs.readFile(path.resolve(__dirname, './partials/shoutbox.tpl'), function (err, partial) { | ||
callback(err, partial.toString()); | ||
}); | ||
}, | ||
"getOriginalShout": function(socket, data, callback) { | ||
@@ -305,4 +304,2 @@ if (data.sid && data.sid.length > 0) { | ||
var messages = []; | ||
function getShout(sid, next) { | ||
@@ -322,4 +319,3 @@ db.getObject('shout:' + sid, function(err, message) { | ||
message.sid = sid; | ||
messages.push(message); | ||
next(null); | ||
next(null, message); | ||
}); | ||
@@ -330,8 +326,3 @@ }); | ||
async.eachSeries(sids, getShout, function(err) { | ||
if (err) { | ||
return callback(err, null); | ||
} | ||
callback(null, messages); | ||
}); | ||
async.map(sids, getShout, callback); | ||
}); | ||
@@ -422,3 +413,2 @@ }, | ||
} | ||
var removedSids = []; | ||
@@ -436,3 +426,3 @@ function deleteShout(sid, next) { | ||
async.eachSeries(sids, deleteShout, function(err) { | ||
async.map(sids, deleteShout, function(err) { | ||
if (err) { | ||
@@ -439,0 +429,0 @@ return callback(err, false); |
{ | ||
"name": "nodebb-plugin-shoutbox", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "NodeBB Shoutbox Plugin", | ||
@@ -5,0 +5,0 @@ "main": "library.js", |
@@ -5,2 +5,3 @@ { | ||
"description": "NodeBB Plugin Shoutbox", | ||
"minver": "0.3", | ||
"url": "https://github.com/BitBangersCode/nodebb-plugin-shoutbox", | ||
@@ -16,6 +17,8 @@ "library": "./library.js", | ||
], | ||
"staticDir": "./public", | ||
"staticDirs": { | ||
"shoutbox": "./public" | ||
}, | ||
"css": [ | ||
"css/style.css" | ||
"shoutbox/css/style.css" | ||
] | ||
} |
@@ -5,3 +5,3 @@ $(document).ready(function() { | ||
requirejs([ | ||
'plugins/nodebb-plugin-shoutbox/js/shoutbox.js' | ||
'plugins/shoutbox/js/shoutbox.js' | ||
], function(shoutBox) { | ||
@@ -8,0 +8,0 @@ shoutBox.base.init(data.url); |
@@ -136,5 +136,6 @@ define(['string'], function(S) { | ||
box.utils.getConfig(function() { | ||
socket.emit(box.vars.sockets.get_partial, function(err, partial) { | ||
templates.preload_template('shoutbox', function() { | ||
var partial = templates['shoutbox'].parse({}); | ||
var loc = box.vars.config.pagePosition; | ||
if (loc !== 'none' && !err) { | ||
if (loc !== 'none') { | ||
if (loc === 'top') { | ||
@@ -153,3 +154,3 @@ $(partial).insertBefore('.home'); | ||
"checkAnon": function(callback) { | ||
if (app.uid === null) { | ||
if (app.uid === 0) { | ||
return callback(true); | ||
@@ -454,8 +455,10 @@ } | ||
module.box.addShout(module.base.getShoutPanel(), data); | ||
if (box.utils.getSetting('notification')) { | ||
app.alternatingTitle(box.vars.titleAlert.replace(/%u/g, data.username)); | ||
if (data.fromuid !== app.uid) { | ||
if (box.utils.getSetting('notification')) { | ||
app.alternatingTitle(box.vars.titleAlert.replace(/%u/g, data.username)); | ||
} | ||
if (box.utils.getSetting('sound')) { | ||
$('#shoutbox-sounds-notification')[0].play(); | ||
} | ||
} | ||
if (box.utils.getSetting('sound')) { | ||
$('#shoutbox-sounds-notification')[0].play(); | ||
} | ||
} | ||
@@ -462,0 +465,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
42034
1006