mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-12 08:55:47 +01:00
tweaks to composer pushing, fixed random extra letter in footer js
This commit is contained in:
@@ -109,8 +109,6 @@ var socket,
|
||||
// timeout default = permanent
|
||||
// location : alert_window (default) or content
|
||||
app.alert = function(params) {
|
||||
|
||||
|
||||
var alert_id = 'alert_button_' + ((params.alert_id) ? params.alert_id : new Date().getTime());
|
||||
|
||||
var alert = $('#'+alert_id);
|
||||
@@ -121,7 +119,6 @@ var socket,
|
||||
alert.attr('class', "alert toaster-alert " + ((params.type=='warning') ? '' : "alert-" + params.type));
|
||||
}
|
||||
else {
|
||||
|
||||
var div = document.createElement('div'),
|
||||
button = document.createElement('button'),
|
||||
strong = document.createElement('strong'),
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
socket.emit('user.latest', {});
|
||||
socket.on('user.latest', function(data) {
|
||||
if (data.username == '') {
|
||||
latest_user.innerHTML = '';y
|
||||
latest_user.innerHTML = '';
|
||||
} else {
|
||||
latest_user.innerHTML = "The most recent user to register is <b><a href='/users/"+data.username+"'>" + data.username + "</a></b>.";
|
||||
}
|
||||
|
||||
@@ -41,21 +41,34 @@ define(function() {
|
||||
document.body.insertBefore(composer.postContainer, composer.btnContainer);
|
||||
|
||||
socket.on('api:composer.push', function(threadData) {
|
||||
var uuid = utils.generateUUID(),
|
||||
btnEl = document.createElement('li');
|
||||
btnEl.innerHTML = '<a href="#"><img src="/graph/users/' + threadData.username + '/picture" /><span>' + (!threadData.cid ? (threadData.title || '') : 'New Topic') + '</span></a>';
|
||||
btnEl.setAttribute('data-uuid', uuid);
|
||||
composer.listEl.appendChild(btnEl);
|
||||
composer.posts[uuid] = {
|
||||
tid: threadData.tid,
|
||||
cid: threadData.cid,
|
||||
pid: threadData.pid,
|
||||
title: threadData.title || '',
|
||||
body: threadData.body || ''
|
||||
};
|
||||
composer.active++;
|
||||
composer.update();
|
||||
composer.load(uuid);
|
||||
if (!threadData.error) {
|
||||
var uuid = utils.generateUUID(),
|
||||
btnEl = document.createElement('li');
|
||||
btnEl.innerHTML = '<a href="#"><img src="/graph/users/' + threadData.username + '/picture" /><span>' + (!threadData.cid ? (threadData.title || '') : 'New Topic') + '</span></a>';
|
||||
btnEl.setAttribute('data-uuid', uuid);
|
||||
composer.listEl.appendChild(btnEl);
|
||||
composer.posts[uuid] = {
|
||||
tid: threadData.tid,
|
||||
cid: threadData.cid,
|
||||
pid: threadData.pid,
|
||||
title: threadData.title || '',
|
||||
body: threadData.body || ''
|
||||
};
|
||||
composer.active++;
|
||||
composer.update();
|
||||
composer.load(uuid);
|
||||
} else {
|
||||
app.alert({
|
||||
type: 'error',
|
||||
timeout: 5000,
|
||||
alert_id: 'post_error',
|
||||
title: 'Please Log In to Post',
|
||||
message: 'Posting is currently restricted to registered members only, click here to log in',
|
||||
clickfn: function() {
|
||||
ajaxify.go('login');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
socket.on('api:composer.editCheck', function(editCheck) {
|
||||
|
||||
@@ -308,38 +308,44 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
|
||||
});
|
||||
|
||||
socket.on('api:composer.push', function(data) {
|
||||
if (parseInt(data.tid) > 0) {
|
||||
topics.get_topic(data.tid, uid, function(topicData) {
|
||||
topicData.tid = data.tid;
|
||||
socket.emit('api:composer.push', topicData);
|
||||
});
|
||||
} else if (parseInt(data.cid) > 0) {
|
||||
user.getUserField(uid, 'username', function(username) {
|
||||
socket.emit('api:composer.push', {
|
||||
tid: 0,
|
||||
cid: data.cid,
|
||||
username: username,
|
||||
title: undefined
|
||||
if (uid > 0) {
|
||||
if (parseInt(data.tid) > 0) {
|
||||
topics.get_topic(data.tid, uid, function(topicData) {
|
||||
topicData.tid = data.tid;
|
||||
socket.emit('api:composer.push', topicData);
|
||||
});
|
||||
});
|
||||
} else if (parseInt(data.pid) > 0) {
|
||||
async.parallel([
|
||||
function(next) {
|
||||
posts.getRawContent(data.pid, function(raw) {
|
||||
next(null, raw);
|
||||
} else if (parseInt(data.cid) > 0) {
|
||||
user.getUserField(uid, 'username', function(username) {
|
||||
socket.emit('api:composer.push', {
|
||||
tid: 0,
|
||||
cid: data.cid,
|
||||
username: username,
|
||||
title: undefined
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
topics.getTitle(data.pid, function(title) {
|
||||
next(null, title);
|
||||
});
|
||||
}
|
||||
], function(err, results) {
|
||||
socket.emit('api:composer.push', {
|
||||
title: results[1],
|
||||
pid: data.pid,
|
||||
body: results[0]
|
||||
});
|
||||
} else if (parseInt(data.pid) > 0) {
|
||||
async.parallel([
|
||||
function(next) {
|
||||
posts.getRawContent(data.pid, function(raw) {
|
||||
next(null, raw);
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
topics.getTitle(data.pid, function(title) {
|
||||
next(null, title);
|
||||
});
|
||||
}
|
||||
], function(err, results) {
|
||||
socket.emit('api:composer.push', {
|
||||
title: results[1],
|
||||
pid: data.pid,
|
||||
body: results[0]
|
||||
});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
socket.emit('api:composer.push', {
|
||||
error: 'no-uid'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user