|
$(document).ready(function()
{
$('#users_refresh').click(refreshUsers);
$('#login_button').click(function()
{
Forums.Login($('#un').val(), $('#pw').val(), function(result)
{
if (result)
{
window.location = window.location;
}
else
{
alert('Login failed. Please try again.');
return;
}
}, alertResult);
});
refreshPosts();
if ($('#users').length > 0) refreshUsers();
});
function refreshPosts()
{
Forums.GetForumPosts(setContent, setContent, '#posts');
}
function refreshUsers()
{
Forums.GetUsers(setContent, setContent, '#users');
}
function addPost()
{
var text = $('#post_text').val();
if (text == '')
{
alert('You must provide post text');
return;
}
Forums.AddPost(text, function()
{
$('#post_text').val('');
refreshPosts();
}, alertResult);
}
function approvePost(id)
{
if (!confirm('Are you sure you want to approve this post?')) return;
Forums.ApprovePost(id, refreshPosts, alertResult);
}
function deletePost(id)
{
if (!confirm('Are you sure you want to delete this post?')) return;
Forums.DeletePost(id, refreshPosts, alertResult);
}
function addUser()
{
var un = $('#new_un').val();
var pw = $('#new_pw').val();
var role = $('#new_role').val();
if (un == '' || pw == '')
{
alert('You must provide a user name and password');
return;
}
Forums.AddUser(un, pw, role, function()
{
$('#new_un').val('');
$('#new_pw').val('');
$('#new_role').val('User');
refreshUsers();
}, alertResult);
}
function deleteUser(un)
{
if (!confirm('Are you sure you want to delete ' + un + '?')) return;
Forums.DeleteUser(un, refreshUsers, alertResult);
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Clayton Rumley is web developer for hire from Winnipeg, Manitoba, Canada.