includes/clientside/static/comments.js
changeset 86 c162ca39db8f
parent 85 7c68a18a27be
child 102 d807dcd7aed7
equal deleted inserted replaced
85:7c68a18a27be 86:c162ca39db8f
    32       }
    32       }
    33       var response = parseJSON(ajax.responseText);
    33       var response = parseJSON(ajax.responseText);
    34       switch(response.mode)
    34       switch(response.mode)
    35       {
    35       {
    36         case 'fetch':
    36         case 'fetch':
    37           document.getElementById('ajaxEditContainer').innerHTML = 'Rendering response...';
    37           document.getElementById('ajaxEditContainer').innerHTML = '<div class="wait-box">Rendering '+response.count_total+' comments...</div>';
    38           if(response.template)
    38           if(response.template)
    39             comment_template = response.template;
    39             comment_template = response.template;
    40           setAjaxLoading();
    40           setAjaxLoading();
    41           renderComments(response);
    41           renderComments(response);
    42           unsetAjaxLoading();
    42           unsetAjaxLoading();
    51           alert('Your comment has been posted. If it does not appear right away, it is probably awaiting approval.');
    51           alert('Your comment has been posted. If it does not appear right away, it is probably awaiting approval.');
    52           hideCommentForm();
    52           hideCommentForm();
    53           materializeComment(response);
    53           materializeComment(response);
    54           break;
    54           break;
    55         case 'error':
    55         case 'error':
    56           alert(response.error);
    56           new messagebox(MB_OK|MB_ICONSTOP, ( response.title ? response.title : 'Error fetching comment data' ), response.error);
    57           break;
    57           break;
    58         default:
    58         default:
    59           alert(ajax.responseText);
    59           alert(ajax.responseText);
    60           break;
    60           break;
    61       }
    61       }
   181   // User level
   181   // User level
   182   tplvars.USER_LEVEL = 'Guest';
   182   tplvars.USER_LEVEL = 'Guest';
   183   if ( this_comment.user_level >= data.user_level.member ) tplvars.USER_LEVEL = 'Member';
   183   if ( this_comment.user_level >= data.user_level.member ) tplvars.USER_LEVEL = 'Member';
   184   if ( this_comment.user_level >= data.user_level.mod ) tplvars.USER_LEVEL = 'Moderator';
   184   if ( this_comment.user_level >= data.user_level.mod ) tplvars.USER_LEVEL = 'Moderator';
   185   if ( this_comment.user_level >= data.user_level.admin ) tplvars.USER_LEVEL = 'Administrator';
   185   if ( this_comment.user_level >= data.user_level.admin ) tplvars.USER_LEVEL = 'Administrator';
   186   
   186                               
   187   // Send PM link
   187   // Send PM link
   188   tplvars.SEND_PM_LINK=(this_comment.user_id>1)?'<a onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/Compose/To/' + ( this_comment.name.replace(/ /g, '_') )) +'">Send private message</a><br />':'';
   188   tplvars.SEND_PM_LINK=(this_comment.user_id>1 && data.logged_in)?'<a onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/Compose/To/' + ( this_comment.name.replace(/ /g, '_') )) +'">Send private message</a><br />':'';
   189   
   189   
   190   // Add buddy link
   190   // Add buddy link
   191   tplvars.ADD_BUDDY_LINK=(this_comment.user_id>1)?'<a onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/FriendList/Add/' + ( this_comment.name.replace(/ /g, '_') )) +'">Add to buddy list</a><br />':'';
   191   tplvars.ADD_BUDDY_LINK=(this_comment.user_id>1 && data.logged_in)?'<a onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/FriendList/Add/' + ( this_comment.name.replace(/ /g, '_') )) +'">Add to buddy list</a><br />':'';
   192   
   192   
   193   // Edit link
   193   // Edit link
   194   tplvars.EDIT_LINK='<a href="#edit_'+i+'" onclick="editComment(\''+i+'\', this); return false;" id="cmteditlink_'+i+'">edit</a>';
   194   tplvars.EDIT_LINK='<a href="#edit_'+i+'" onclick="editComment(\''+i+'\', this); return false;" id="cmteditlink_'+i+'">edit</a>';
   195   
   195   
   196   // Delete link
   196   // Delete link