mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	replies are up
This commit is contained in:
		| @@ -79,17 +79,57 @@ var socket, | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	var post_window = null, | 	var post_window = null, | ||||||
| 		mode = 'topic', | 		submit_post_btn = null, | ||||||
| 		topic_id = null; | 		post_title = null, | ||||||
|  | 		post_content = null; | ||||||
|  |  | ||||||
|  |  | ||||||
| 	app.open_post_window = function(post_mode, id) { | 	app.open_post_window = function(post_mode, id) { | ||||||
|  | 		submit_post_btn = submit_post_btn || document.getElementById('submit_post_btn'); | ||||||
|  | 		post_title = post_title || document.getElementById('post_title'); | ||||||
|  | 		post_content = post_content || document.getElementById('post_content'); | ||||||
|  |  | ||||||
|  |  | ||||||
| 		post_window = post_window || document.getElementById('post_window'); | 		post_window = post_window || document.getElementById('post_window'); | ||||||
| 		jQuery(post_window).slideToggle(250); | 		jQuery(post_window).slideToggle(250); | ||||||
| 		document.getElementById('post_title').focus(); |  | ||||||
|  |  | ||||||
| 		mode = (post_mode == null) ? 'topic' : mode; | 		if (post_mode == null || post_mode == 'topic') { | ||||||
| 		topic_id = (mode == 'reply') ? topic_id : null; | 			post_title.style.display = 'block'; | ||||||
|  | 			post_title.focus(); | ||||||
|  | 			submit_post_btn.onclick = function() { | ||||||
|  | 				app.post_topic(); | ||||||
|  | 			} | ||||||
|  | 		} else { | ||||||
|  | 			post_title.style.display = 'none'; | ||||||
|  | 			post_content.focus(); | ||||||
|  | 			submit_post_btn.onclick = function() { | ||||||
|  | 				app.post_reply(id) | ||||||
|  | 			}  | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
|  | 	app.post_reply = function(topic_id) { | ||||||
|  | 		var	content = document.getElementById('post_content').value; | ||||||
|  |  | ||||||
|  | 		if (content.length < 5) { | ||||||
|  | 			app.alert({ | ||||||
|  | 				title: 'Reply Failure', | ||||||
|  | 				message: 'You need to write more dude.', | ||||||
|  | 				type: 'error', | ||||||
|  | 				timeout: 2000 | ||||||
|  | 			});	 | ||||||
|  |  | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  |  | ||||||
|  | 		socket.emit('api:posts.reply', { | ||||||
|  | 			'topic_id' : topic_id, | ||||||
|  | 			'content' : content  | ||||||
|  | 		}); | ||||||
|  | 		jQuery(post_window).slideToggle(250); | ||||||
|  |  | ||||||
|  | 	}; | ||||||
| 	app.post_topic = function() { | 	app.post_topic = function() { | ||||||
| 		var title = document.getElementById('post_title').value, | 		var title = document.getElementById('post_title').value, | ||||||
| 			content = document.getElementById('post_content').value; | 			content = document.getElementById('post_content').value; | ||||||
| @@ -99,10 +139,7 @@ var socket, | |||||||
| 				title: 'Topic Post Failure', | 				title: 'Topic Post Failure', | ||||||
| 				message: 'You need to write more dude.', | 				message: 'You need to write more dude.', | ||||||
| 				type: 'error', | 				type: 'error', | ||||||
| 				timeout: 2000, | 				timeout: 2000 | ||||||
| 				clickfn: function() { |  | ||||||
| 					ajaxify.go('register'); |  | ||||||
| 				} |  | ||||||
| 			});	 | 			});	 | ||||||
|  |  | ||||||
| 			return; | 			return; | ||||||
|   | |||||||
| @@ -90,10 +90,10 @@ | |||||||
| 		border: 1px solid #eee; | 		border: 1px solid #eee; | ||||||
| 		margin-top: 50px; | 		margin-top: 50px; | ||||||
| 	} | 	} | ||||||
| 	.topic-container li.topic-row:nth-child(odd) { | 	.topic-container a:nth-child(odd) li.topic-row { | ||||||
| 		background-color:#fdfdfd; | 		background-color:#fdfdfd; | ||||||
| 	} | 	} | ||||||
| 	.topic-container li.topic-row:nth-child(even) { | 	.topic-container a:nth-child(even) li.topic-row { | ||||||
| 		background-color:#fff; | 		background-color:#fff; | ||||||
| 	} | 	} | ||||||
| 	.topic-container li.topic-row { | 	.topic-container li.topic-row { | ||||||
| @@ -161,7 +161,7 @@ | |||||||
| 						<a class="btn btn-link" href="#" tabindex="-1"><i class="icon-list"></i></a> | 						<a class="btn btn-link" href="#" tabindex="-1"><i class="icon-list"></i></a> | ||||||
| 					</div> | 					</div> | ||||||
| 					<div class="btn-group" style="float: right; margin-right: -12px"> | 					<div class="btn-group" style="float: right; margin-right: -12px"> | ||||||
| 						<a class="btn" onclick="app.post_topic()"><i class="icon-ok"></i> Submit</a> | 						<a id="submit_post_btn" class="btn" onclick="app.post_topic()"><i class="icon-ok"></i> Submit</a> | ||||||
| 						<a class="btn" onclick="jQuery(post_window).slideToggle(250);"><i class="icon-remove"></i> Discard</a> | 						<a class="btn" onclick="jQuery(post_window).slideToggle(250);"><i class="icon-remove"></i> Discard</a> | ||||||
| 					</div> | 					</div> | ||||||
| 				</div> | 				</div> | ||||||
|   | |||||||
							
								
								
									
										13
									
								
								src/posts.js
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								src/posts.js
									
									
									
									
									
								
							| @@ -48,7 +48,7 @@ var	RDB = require('./redis.js'), | |||||||
| 							}); | 							}); | ||||||
| 						} | 						} | ||||||
|  |  | ||||||
| 						callback({'posts': posts, 'TOPIC_ID': tid}); | 						callback({'TOPIC_ID': tid, 'posts': posts}); | ||||||
| 					}); | 					}); | ||||||
| 			} else { | 			} else { | ||||||
| 				callback({}); | 				callback({}); | ||||||
| @@ -60,8 +60,17 @@ var	RDB = require('./redis.js'), | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  |  | ||||||
| 	Posts.reply = function() { | 	Posts.reply = function(tid, uid, content) { | ||||||
|  | 		Posts.create(uid, content, function(pid) { | ||||||
|  | 			RDB.rpush('tid:' + tid + ':posts', pid); | ||||||
|  |  | ||||||
|  | 			global.socket.emit('event:alert', { | ||||||
|  | 				title: 'Reply Successful', | ||||||
|  | 				message: 'You have successfully replied. Click here to view your reply.', | ||||||
|  | 				type: 'notify', | ||||||
|  | 				timeout: 2000 | ||||||
|  | 			}); | ||||||
|  | 		}); | ||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
| 	Posts.create = function(uid, content, callback) { | 	Posts.create = function(uid, content, callback) { | ||||||
|   | |||||||
| @@ -76,6 +76,10 @@ | |||||||
| 		db.lpush(key, item); | 		db.lpush(key, item); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	RedisDB.rpush = function(key, item) { | ||||||
|  | 		db.rpush(key, item); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	RedisDB.lrange = function(key, start, end, callback, error_handler) { | 	RedisDB.lrange = function(key, start, end, callback, error_handler) { | ||||||
| 		db.lrange(key, start, end, function(error, data) { | 		db.lrange(key, start, end, function(error, data) { | ||||||
| 			return_handler(error, data, callback, error_handler); | 			return_handler(error, data, callback, error_handler); | ||||||
|   | |||||||
| @@ -93,6 +93,10 @@ var	SocketIO = require('socket.io').listen(global.server), | |||||||
| 			modules.topics.post(uid, data.title, data.content); | 			modules.topics.post(uid, data.title, data.content); | ||||||
| 		}); | 		}); | ||||||
|  |  | ||||||
|  | 		socket.on('api:posts.reply', function(data) { | ||||||
|  | 			modules.posts.reply(data.topic_id, uid, data.content); | ||||||
|  | 		}); | ||||||
|  |  | ||||||
| 		socket.on('api:user.active.get', function() { | 		socket.on('api:user.active.get', function() { | ||||||
| 			modules.user.active.get(); | 			modules.user.active.get(); | ||||||
| 		}); | 		}); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user