function request_friend( mingle_url, user_id, friend_id, friend_requested_text ) { mngl_replace_id_with_loading_indicator('friend_request_button-' + friend_id); jQuery.ajax( { type: "POST", url: mingle_url, data: "controller=friends&action=friend_request&user_id=" + user_id + "&friend_id=" + friend_id, success: function(html) { jQuery("#friend_request_button-" + friend_id ).replaceWith( friend_requested_text ); } }); } function mngl_escape(message) { // escape problematic characters -- don't escape utf8 chars return message.replace(/&/g,'%26').replace(/=/g,'%3D').replace(/ /g, '%20').replace(/\?/g, '%3F'); } function post_to_board( mingle_url, owner_id, author_id, message, controller ) { mngl_replace_id_with_loading_indicator('mngl-board-post-button'); jQuery.ajax( { type: "POST", url: mingle_url, data: "controller=" + controller + "&action=post&owner_id=" + owner_id + "&author_id=" + author_id + "&message=" + mngl_escape(message), success: function(html) { jQuery('.mngl-board').replaceWith('
'+html+'
'); mngl_load_growables(); } }); } function mngl_show_older_posts( pagenum, loc, screenname ) { mngl_replace_id_with_loading_indicator('mngl-older-posts'); jQuery.ajax( { type: "POST", url: '/index.php?plugin=mingle', data: "controller=boards&action=older_posts&mdp=" + pagenum + "&loc=" + loc + "&u=" + screenname, success: function(html) { jQuery('#mngl-older-posts').replaceWith(html); mngl_load_growables(); } }); } function comment_on_post( mingle_url, author_id, board_post_id, message, controller ) { mngl_replace_id_with_loading_indicator('mngl-comment-button-' + board_post_id); jQuery.ajax( { type: "POST", url: mingle_url, data: "controller=" + controller + "&action=comment&author_id=" + author_id + "&board_post_id=" + board_post_id + "&message=" + mngl_escape(message), success: function(html) { jQuery('.mngl-board').replaceWith('
'+html+'
'); mngl_load_growables(); } }); } function delete_board_post( mingle_url, board_post_id, controller ) { if(confirm("Are you sure you want to delete this post?")) { jQuery.ajax( { type: "POST", url: mingle_url, data: "controller=" + controller + "&action=delete_post&board_post_id=" + board_post_id, success: function(html) { jQuery('.mngl-board').replaceWith('
'+html+'
'); mngl_load_growables(); } }); } } function delete_board_comment( mingle_url, board_comment_id, controller ) { if(confirm("Are you sure you want to delete this comment?")) { jQuery.ajax( { type: "POST", url: mingle_url, data: "controller=" + controller + "&action=delete_comment&board_comment_id=" + board_comment_id, success: function(html) { jQuery('.mngl-board').replaceWith('
'+html+'
'); mngl_load_growables(); } }); } } function toggle_comment_form( update_id ) { jQuery('#mngl-board-comment-list-' + update_id).show(); jQuery('#mngl-comment-form-' + update_id).toggle(); jQuery('#mngl-fake-board-comment-' + update_id).toggle(); jQuery('#mngl-board-comment-input-' + update_id).focus(); } function show_board_post_form() { jQuery('#mngl-fake-board-post-form').toggle(); jQuery('#mngl-board-post-form').toggle(); jQuery('#mngl-board-post-input').focus(); } function toggle_hidden_comments(board_post_id) { jQuery('.mngl-hidden-comment-'+board_post_id).show(); jQuery('#mngl-show-hidden-comments-'+board_post_id).hide(); } function delete_friend( mingle_url, user_id, friend_id ) { if(confirm("Are you sure you want to delete this friend?")) { jQuery.ajax( { type: "POST", url: mingle_url, data: "controller=friends&action=delete_friend&user_id=" + user_id + "&friend_id=" + friend_id, success: function(html) { jQuery('#mngl-friend-'+friend_id).replaceWith(''); } }); } } function accept_friend_request( mingle_url, request_id, requestor_name ) { mngl_replace_id_with_loading_indicator('request-' + request_id); jQuery.ajax( { type: "POST", url: mingle_url, data: "controller=friends&action=accept_friend&request_id=" + request_id, success: function(html) { jQuery( '#request-' + request_id ).replaceWith( 'You\'re now friends with ' + requestor_name ); } }); } function ignore_friend_request( mingle_url, request_id ) { mngl_replace_id_with_loading_indicator('request-' + request_id); jQuery.ajax( { type: "POST", url: mingle_url, data: "controller=friends&action=ignore_friend&request_id=" + request_id, success: function(html) { jQuery( '#request-' + request_id ).replaceWith(' '); } }); } function mngl_search_directory( search_query ) { mngl_replace_id_with_loading_indicator('mngl-profile-results'); jQuery.ajax( { type: "POST", url: '/index.php?plugin=mingle', data: "&controller=profile&action=search&q=" + search_query, success: function(html) { jQuery( '#mngl-profile-results' ).replaceWith(html); } }); } function mngl_search_friends( search_query, page_params ) { mngl_replace_id_with_loading_indicator('mngl-friends-directory'); jQuery.ajax( { type: "POST", url: '/index.php?plugin=mingle', data: "&controller=friends&action=search&q=" + search_query + page_params, success: function(html) { jQuery( '#mngl-friends-directory' ).replaceWith(html); } }); } function delete_profile_avatar( mingle_url, user_id ) { if(confirm("Are you sure you want to delete your avatar?")) { jQuery.ajax( { type: "POST", url: mingle_url, data: "controller=profile&action=delete_avatar&user_id=" + user_id, success: function(html) { jQuery('#mngl-avatar-edit-display').replaceWith(html); } }); } } function mngl_toggle_two_ids( first_id, second_id ) { jQuery(first_id).toggle(); jQuery(second_id).toggle(); } function mngl_show_search_form() { jQuery('#mngl-fake-search-form').hide(); jQuery('#mngl-search-form').show(); jQuery('#mngl-search-input').focus(); } function mngl_remove_tag( html_tag ) { jQuery( html_tag ).remove(); } function mngl_add_default_user() { jQuery.ajax( { type: "POST", url: '/index.php?plugin=mingle', data: "controller=options&action=add_default_user", success: function(html) { jQuery('.mngl-default-friends-table').append(html); } }); } function mngl_replace_id_with_loading_indicator(tagname) { jQuery('#'+tagname).replaceWith('Loading...'); } function mngl_load_growables() { jQuery(".mngl-hidden").show(); jQuery(".mngl-growable").elastic(); jQuery(".mngl-hidden").hide(); } jQuery(document).ready(function() { mngl_load_growables(); });