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
|
// timeout default = permanent
|
||||||
// location : alert_window (default) or content
|
// location : alert_window (default) or content
|
||||||
app.alert = function(params) {
|
app.alert = function(params) {
|
||||||
|
|
||||||
|
|
||||||
var alert_id = 'alert_button_' + ((params.alert_id) ? params.alert_id : new Date().getTime());
|
var alert_id = 'alert_button_' + ((params.alert_id) ? params.alert_id : new Date().getTime());
|
||||||
|
|
||||||
var alert = $('#'+alert_id);
|
var alert = $('#'+alert_id);
|
||||||
@@ -121,7 +119,6 @@ var socket,
|
|||||||
alert.attr('class', "alert toaster-alert " + ((params.type=='warning') ? '' : "alert-" + params.type));
|
alert.attr('class', "alert toaster-alert " + ((params.type=='warning') ? '' : "alert-" + params.type));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
var div = document.createElement('div'),
|
var div = document.createElement('div'),
|
||||||
button = document.createElement('button'),
|
button = document.createElement('button'),
|
||||||
strong = document.createElement('strong'),
|
strong = document.createElement('strong'),
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
socket.emit('user.latest', {});
|
socket.emit('user.latest', {});
|
||||||
socket.on('user.latest', function(data) {
|
socket.on('user.latest', function(data) {
|
||||||
if (data.username == '') {
|
if (data.username == '') {
|
||||||
latest_user.innerHTML = '';y
|
latest_user.innerHTML = '';
|
||||||
} else {
|
} else {
|
||||||
latest_user.innerHTML = "The most recent user to register is <b><a href='/users/"+data.username+"'>" + data.username + "</a></b>.";
|
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);
|
document.body.insertBefore(composer.postContainer, composer.btnContainer);
|
||||||
|
|
||||||
socket.on('api:composer.push', function(threadData) {
|
socket.on('api:composer.push', function(threadData) {
|
||||||
var uuid = utils.generateUUID(),
|
if (!threadData.error) {
|
||||||
btnEl = document.createElement('li');
|
var uuid = utils.generateUUID(),
|
||||||
btnEl.innerHTML = '<a href="#"><img src="/graph/users/' + threadData.username + '/picture" /><span>' + (!threadData.cid ? (threadData.title || '') : 'New Topic') + '</span></a>';
|
btnEl = document.createElement('li');
|
||||||
btnEl.setAttribute('data-uuid', uuid);
|
btnEl.innerHTML = '<a href="#"><img src="/graph/users/' + threadData.username + '/picture" /><span>' + (!threadData.cid ? (threadData.title || '') : 'New Topic') + '</span></a>';
|
||||||
composer.listEl.appendChild(btnEl);
|
btnEl.setAttribute('data-uuid', uuid);
|
||||||
composer.posts[uuid] = {
|
composer.listEl.appendChild(btnEl);
|
||||||
tid: threadData.tid,
|
composer.posts[uuid] = {
|
||||||
cid: threadData.cid,
|
tid: threadData.tid,
|
||||||
pid: threadData.pid,
|
cid: threadData.cid,
|
||||||
title: threadData.title || '',
|
pid: threadData.pid,
|
||||||
body: threadData.body || ''
|
title: threadData.title || '',
|
||||||
};
|
body: threadData.body || ''
|
||||||
composer.active++;
|
};
|
||||||
composer.update();
|
composer.active++;
|
||||||
composer.load(uuid);
|
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) {
|
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) {
|
socket.on('api:composer.push', function(data) {
|
||||||
if (parseInt(data.tid) > 0) {
|
if (uid > 0) {
|
||||||
topics.get_topic(data.tid, uid, function(topicData) {
|
if (parseInt(data.tid) > 0) {
|
||||||
topicData.tid = data.tid;
|
topics.get_topic(data.tid, uid, function(topicData) {
|
||||||
socket.emit('api:composer.push', 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
|
|
||||||
});
|
});
|
||||||
});
|
} else if (parseInt(data.cid) > 0) {
|
||||||
} else if (parseInt(data.pid) > 0) {
|
user.getUserField(uid, 'username', function(username) {
|
||||||
async.parallel([
|
socket.emit('api:composer.push', {
|
||||||
function(next) {
|
tid: 0,
|
||||||
posts.getRawContent(data.pid, function(raw) {
|
cid: data.cid,
|
||||||
next(null, raw);
|
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