includes/clientside/static/comments.js
author Dan
Fri, 28 Nov 2008 22:10:47 -0500
changeset 750 650924c35957
parent 748 e39454295bbb
child 754 75decd836c94
permissions -rw-r--r--
Fixed: Admin:PageGroups create form did not init properly
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     1
// Comments
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     2
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     3
var comment_template = false;
85
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
     4
var comment_render_track = 0;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     5
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
     6
window.ajaxComments = function(parms)
85
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
     7
{
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
     8
  load_component('l10n');
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
     9
  load_component('paginate');
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
    10
  load_component('template-compiler');
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    11
  setAjaxLoading();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    12
  var pid = strToPageID(title);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    13
  if(!parms)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    14
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    15
    var parms = {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    16
      'mode' : 'fetch'
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    17
    };
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    18
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    19
  parms.page_id = pid[0];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    20
  parms.namespace = pid[1];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    21
  if(comment_template)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    22
    parms.have_template = true;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    23
  parms = ajaxEscape(toJSONString(parms));
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    24
  ajaxPost(stdAjaxPrefix+'&_mode=comments', 'data=' + parms, function() {
407
35d94240a197 Mass-fixed all AJAX functions to also check the HTTP status code before parsing the response
Dan
parents: 359
diff changeset
    25
    if ( ajax.readyState == 4 && ajax.status == 200 ) {
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    26
      unsetAjaxLoading();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    27
      selectButtonMajor('discussion');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    28
      unselectAllButtonsMinor();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    29
      // IE compatibility - doing ajax.responseText.substr() doesn't work
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    30
      var rsptxt = ajax.responseText + '';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    31
      if ( rsptxt.substr(0, 1) != '{' )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    32
      {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    33
        document.getElementById('ajaxEditContainer').innerHTML = '<p>Comment system Javascript runtime: invalid JSON response from server, response text:</p><pre>' + ajax.responseText + '</pre>';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    34
        return false;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    35
      }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    36
      var response = parseJSON(ajax.responseText);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    37
      switch(response.mode)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    38
      {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    39
        case 'fetch':
86
c162ca39db8f Finished pagination code (was incomplete in previous revision) and added a few hacks for an upcoming theme
Dan
parents: 85
diff changeset
    40
          document.getElementById('ajaxEditContainer').innerHTML = '<div class="wait-box">Rendering '+response.count_total+' comments...</div>';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    41
          if(response.template)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    42
            comment_template = response.template;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    43
          setAjaxLoading();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    44
          renderComments(response);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    45
          unsetAjaxLoading();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    46
          break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    47
        case 'redraw':
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    48
          redrawComment(response);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    49
          break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    50
        case 'annihilate':
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    51
          annihiliateComment(response.id);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    52
          break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    53
        case 'materialize':
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
    54
          alert($lang.get('comment_msg_comment_posted'));
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    55
          hideCommentForm();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    56
          materializeComment(response);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    57
          break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    58
        case 'error':
550
685e839d934e Added ability to delete the draft revision; [SECURITY] fixed lack of permission check on draft save; renamed messagebox() constructor to MessageBox() (backward compat. maintained)
Dan
parents: 541
diff changeset
    59
          new MessageBox(MB_OK|MB_ICONSTOP, ( response.title ? response.title : 'Error fetching comment data' ), response.error);
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    60
          break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    61
        default:
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    62
          alert(ajax.responseText);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    63
          break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    64
      }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    65
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    66
  });
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    67
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    68
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
    69
window.renderComments = function(data)
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    70
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    71
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    72
  var html = '';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    73
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    74
  // Header
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    75
  
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
    76
    html += '<h3>' + $lang.get('comment_heading') + '</h3>';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    77
    
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
    78
    var ns = ENANO_PAGE_TYPE;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    79
  
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 407
diff changeset
    80
  // Counters
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    81
    if ( data.auth_mod_comments )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    82
    {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    83
      var cnt = ( data.auth_mod_comments ) ? data.count_total : data.count_appr;
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
    84
      
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
    85
      var subst = {
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
    86
        num_comments: cnt,
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
    87
        page_type: ns
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
    88
      }
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
    89
      var count_msg = ( cnt == 0 ) ? $lang.get('comment_msg_count_zero', subst) : ( ( cnt == 1 ) ? $lang.get('comment_msg_count_one', subst) : $lang.get('comment_msg_count_plural', subst) );
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
    90
      
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
    91
      html += "<p id=\"comment_status\"><span>" + count_msg + '</span>';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    92
      if ( data.count_unappr > 0 )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    93
      {
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
    94
        html += ' <span style="color: #D84308" id="comment_status_unapp">' + $lang.get('comment_msg_count_unapp_mod', { num_unapp: data.count_unappr }) + '</span>';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    95
      }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    96
      html += '</p>';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    97
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    98
    else
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    99
    {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   100
      var cnt = data.count_appr;
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   101
      
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   102
      var subst = {
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   103
        num_comments: cnt,
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   104
        page_type: ns
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   105
      }
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   106
      var count_msg = ( cnt == 0 ) ? $lang.get('comment_msg_count_zero', subst) : ( ( cnt == 1 ) ? $lang.get('comment_msg_count_one', subst) : $lang.get('comment_msg_count_plural', subst) );
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   107
      
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   108
      html += "<p id=\"comment_status\">" + count_msg;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   109
      if ( data.count_unappr > 0 )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   110
      {
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   111
        var unappr_msg  = ( data.count_unappr == 1 ) ? $lang.get('comment_msg_count_unapp_one') : $lang.get('comment_msg_count_unapp_plural', { num_unapp: data.count_unappr });
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   112
        html += ' ' + unappr_msg;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   113
      }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   114
      html += '</p>';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   115
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   116
    
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   117
  // Comment display
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   118
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   119
  if ( data.count_total > 0 )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   120
  {
85
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   121
    comment_render_track = 0;
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   122
    var commentpages = new paginator(data.comments, _render_comment, 0, 10, data);
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   123
    html += commentpages.html;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   124
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   125
  
74
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 29
diff changeset
   126
  if ( data.auth_post_comments )
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 29
diff changeset
   127
  {
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 29
diff changeset
   128
    // Posting form
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   129
  
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   130
    html += '<h3>' + $lang.get('comment_postform_title') + '</h3>';
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   131
    html += '<p>' + $lang.get('comment_postform_blurb');
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   132
    if ( data.approval_needed )
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   133
      html+=' ' + $lang.get('comment_postform_blurb_unapp');
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   134
    html += ' <a id="leave_comment_button" href="#" onclick="displayCommentForm(); return false;">' + $lang.get('comment_postform_blurb_link') + '</a></p>';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   135
    html += '<div id="comment_form" style="display: none;">';
541
acb7e23b6ffa Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents: 420
diff changeset
   136
    html += '  <table border="0" style="width: 100%;">';
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   137
    html += '    <tr><td>' + $lang.get('comment_postform_field_name') + '</td><td>';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   138
    if ( data.user_id > 1 ) html += data.username + '<input id="commentform_name" type="hidden" value="'+data.username+'" size="40" />';
541
acb7e23b6ffa Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents: 420
diff changeset
   139
    else html += '<input id="commentform_name" type="text" size="40" style="width: 100%;" />';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   140
    html += '    </td></tr>';
541
acb7e23b6ffa Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents: 420
diff changeset
   141
    html += '    <tr><td>' + $lang.get('comment_postform_field_subject') + '</td><td><input id="commentform_subject" type="text" size="40" style="width: 100%;" /></td></tr>';
acb7e23b6ffa Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents: 420
diff changeset
   142
    html += '    <tr><td>' + $lang.get('comment_postform_field_comment') + '</td><td><textarea id="commentform_message" rows="15" cols="50" style="width: 100%;"></textarea></td></tr>';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   143
    if ( !data.logged_in && data.guest_posting == '1' )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   144
    {
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   145
      html += '  <tr><td>' + $lang.get('comment_postform_field_captcha_title') + '<br /><small>' + $lang.get('comment_postform_field_captcha_blurb') + '</small></td><td>';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   146
      html += '  <img alt="CAPTCHA image" src="'+makeUrlNS('Special', 'Captcha/' + data.captcha)+'" onclick="this.src=\''+makeUrlNS('Special', 'Captcha/' + data.captcha)+'/\'+Math.floor(Math.random()*10000000);" style="cursor: pointer;" /><br />';
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   147
      html += '  ' + $lang.get('comment_postform_field_captcha_label') + ' <input type="text" size="8" id="commentform_captcha" />';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   148
      html += '  <!-- This input is used to track the ID of the CAPTCHA image --> <input type="hidden" id="commentform_captcha_id" value="'+data.captcha+'" />';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   149
      html += '  </td></tr>';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   150
    }
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   151
    html += '    <tr><td colspan="2" style="text-align: center;"><input type="button" onclick="submitComment();" value="' + $lang.get('comment_postform_btn_submit') + '" /></td></tr>';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   152
    html += '  </table>';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   153
    html += '</div>';
74
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 29
diff changeset
   154
  }
68469a95658d Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents: 29
diff changeset
   155
    
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   156
  document.getElementById('ajaxEditContainer').innerHTML = html;
748
e39454295bbb Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
parents: 582
diff changeset
   157
  if ( document.getElementById('commentform_message') )
e39454295bbb Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
parents: 582
diff changeset
   158
  {
e39454295bbb Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
parents: 582
diff changeset
   159
    document.getElementById('commentform_message').allow_wysiwyg = data.auth_edit_wysiwyg
e39454295bbb Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
parents: 582
diff changeset
   160
  }
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   161
  
102
d807dcd7aed7 [comments] fixed edit button (source wasn't getting filled)
Dan
parents: 86
diff changeset
   162
  for ( i = 0; i < data.comments.length; i++ )
d807dcd7aed7 [comments] fixed edit button (source wasn't getting filled)
Dan
parents: 86
diff changeset
   163
  {
d807dcd7aed7 [comments] fixed edit button (source wasn't getting filled)
Dan
parents: 86
diff changeset
   164
    document.getElementById('comment_source_'+i).value = data.comments[i].comment_source;
d807dcd7aed7 [comments] fixed edit button (source wasn't getting filled)
Dan
parents: 86
diff changeset
   165
  }
85
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   166
  
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   167
}
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   168
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   169
var _render_comment = function(this_comment, data)
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   170
{
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   171
  var i = comment_render_track;
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   172
  comment_render_track++;
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   173
  var parser = new templateParser(comment_template);
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   174
  var tplvars = new Object();
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   175
  
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   176
  if ( this_comment.approved != '1' && !data.auth_mod_comments )
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   177
    return '';
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   178
  
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   179
  tplvars.ID = i;
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   180
  tplvars.DATETIME = this_comment.time;
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   181
  tplvars.SUBJECT = this_comment.subject;
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   182
  tplvars.DATA = this_comment.comment_data;
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   183
  tplvars.SIGNATURE = this_comment.signature;
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   184
  
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   185
  if ( this_comment.approved != '1' )
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   186
    tplvars.SUBJECT += ' <span style="color: #D84308">' + $lang.get('comment_msg_note_unapp') + '</span>';
85
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   187
  
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   188
  // Name
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   189
  tplvars.NAME = this_comment.name;
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   190
  if ( this_comment.user_id > 1 )
541
acb7e23b6ffa Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents: 420
diff changeset
   191
    tplvars.NAME = '<a href="' + makeUrlNS('User', this_comment.name) + '" style="' + this_comment.rank_style + '">' + this_comment.name + '</a>';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   192
  
328
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 214
diff changeset
   193
  // Avatar
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 214
diff changeset
   194
  if ( this_comment.user_has_avatar == '1' )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 214
diff changeset
   195
  {
541
acb7e23b6ffa Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents: 420
diff changeset
   196
    tplvars.AVATAR_URL = this_comment.avatar_path;
328
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 214
diff changeset
   197
    tplvars.USERPAGE_LINK = makeUrlNS('User', this_comment.name);
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 214
diff changeset
   198
    tplvars.AVATAR_ALT = $lang.get('usercp_avatar_image_alt', { username: this_comment.name });
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 214
diff changeset
   199
  }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 214
diff changeset
   200
  
85
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   201
  // User level
541
acb7e23b6ffa Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents: 420
diff changeset
   202
  tplvars.USER_LEVEL = '';
acb7e23b6ffa Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents: 420
diff changeset
   203
  if ( this_comment.user_title )
acb7e23b6ffa Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents: 420
diff changeset
   204
    tplvars.USER_LEVEL += this_comment.user_title;
acb7e23b6ffa Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents: 420
diff changeset
   205
  if ( this_comment.rank_title && this_comment.user_title )
acb7e23b6ffa Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents: 420
diff changeset
   206
    tplvars.USER_LEVEL += '<br />';
acb7e23b6ffa Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents: 420
diff changeset
   207
  if ( this_comment.rank_title )
acb7e23b6ffa Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents: 420
diff changeset
   208
    tplvars.USER_LEVEL += $lang.get(this_comment.rank_title);
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   209
  
85
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   210
  // Send PM link
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   211
  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, '_') )) +'">' + $lang.get('comment_btn_send_privmsg') + '</a><br />':'';
85
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   212
  
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   213
  // Add buddy link
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   214
  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, '_') )) +'">' + $lang.get('comment_btn_add_buddy') + '</a><br />':'';
85
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   215
  
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   216
  // Edit link
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   217
  tplvars.EDIT_LINK='<a href="#edit_'+i+'" onclick="editComment(\''+i+'\', this); return false;" id="cmteditlink_'+i+'">' + $lang.get('comment_btn_edit') + '</a>';
85
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   218
  
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   219
  // Delete link
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   220
  tplvars.DELETE_LINK='<a href="#delete_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">' + $lang.get('comment_btn_delete') + '</a>';
85
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   221
  
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   222
  // Moderation: (Un)approve link
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   223
  var appr = ( this_comment.approved == 1 ) ? $lang.get('comment_btn_mod_unapprove') : $lang.get('comment_btn_mod_approve');
85
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   224
  tplvars.MOD_APPROVE_LINK='<a href="#approve_'+i+'" id="comment_approve_'+i+'" onclick="approveComment(\''+i+'\'); return false;">'+appr+'</a>';
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   225
  
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   226
  // Moderation: Delete post link
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   227
  tplvars.MOD_DELETE_LINK='<a href="#mod_del_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">' + $lang.get('comment_btn_mod_delete') + '</a>';
85
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   228
  
359
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   229
  // Moderation: IP address link
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   230
  if ( this_comment.have_ip )
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   231
  {
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   232
    tplvars.MOD_IP_LINK = '<span id="comment_ip_' + i + '"><a href="#mod_ip_' + i + '" onclick="viewCommentIP(' + this_comment.comment_id + ', ' + i + '); return false;">' + $lang.get('comment_btn_mod_ip_logged') + '</a></span>';
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   233
  }
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   234
  else
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   235
  {
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   236
    tplvars.MOD_IP_LINK = $lang.get('comment_btn_mod_ip_missing');
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   237
  }
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   238
  
85
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   239
  var tplbool = new Object();
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   240
  
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   241
  tplbool.signature = ( this_comment.signature == '' ) ? false : true;
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   242
  tplbool.can_edit = ( data.auth_edit_comments && ( ( this_comment.user_id == data.user_id && data.logged_in ) || data.auth_mod_comments ) );
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   243
  tplbool.auth_mod = data.auth_mod_comments;
108
1c7f59df9474 Implemented some extra functionality for friends/foes in comments; fixed lack of table_prefix in stats.php line 63
Dan
parents: 102
diff changeset
   244
  tplbool.is_friend = ( this_comment.is_buddy == 1 && this_comment.is_friend == 1 );
1c7f59df9474 Implemented some extra functionality for friends/foes in comments; fixed lack of table_prefix in stats.php line 63
Dan
parents: 102
diff changeset
   245
  tplbool.is_foe = ( this_comment.is_buddy == 1 && this_comment.is_friend == 0 );
328
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 214
diff changeset
   246
  tplbool.user_has_avatar = ( this_comment.user_has_avatar == '1' );
108
1c7f59df9474 Implemented some extra functionality for friends/foes in comments; fixed lack of table_prefix in stats.php line 63
Dan
parents: 102
diff changeset
   247
  
1c7f59df9474 Implemented some extra functionality for friends/foes in comments; fixed lack of table_prefix in stats.php line 63
Dan
parents: 102
diff changeset
   248
  if ( tplbool.is_friend )
214
a6ed8b6cdbe1 All on-page AJAX applets should be localized now
Dan
parents: 212
diff changeset
   249
    tplvars.USER_LEVEL += '<br /><b>' + $lang.get('comment_on_friend_list') + '</b>';
108
1c7f59df9474 Implemented some extra functionality for friends/foes in comments; fixed lack of table_prefix in stats.php line 63
Dan
parents: 102
diff changeset
   250
  else if ( tplbool.is_foe )
214
a6ed8b6cdbe1 All on-page AJAX applets should be localized now
Dan
parents: 212
diff changeset
   251
    tplvars.USER_LEVEL += '<br /><b>' + $lang.get('comment_on_foe_list') + '</b>';
85
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   252
  
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   253
  parser.assign_vars(tplvars);
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   254
  parser.assign_bool(tplbool);
7c68a18a27be AJAX comments are now paginated; plugin manager can now show system plugins; typo in installer corrected; links in oxygen/stpatty/admin footers changed to "About Enano" page; 1.0.1 release candidate
Dan
parents: 74
diff changeset
   255
  
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 407
diff changeset
   256
  var ret = '<div id="comment_holder_' + i + '">';
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 407
diff changeset
   257
  ret += '<input type="hidden" value="'+this_comment.comment_id+'" />';
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 407
diff changeset
   258
  ret += '<input type="hidden" id="comment_source_'+i+'" />';
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 407
diff changeset
   259
  ret += parser.run();
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 407
diff changeset
   260
  ret += '</div>';
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 407
diff changeset
   261
  return ret;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   262
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   263
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
   264
window.displayCommentForm = function()
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   265
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   266
  document.getElementById('leave_comment_button').style.display = 'none';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   267
  document.getElementById('comment_form').style.display = 'block';
748
e39454295bbb Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
parents: 582
diff changeset
   268
  if ( $dynano('commentform_message').object.allow_wysiwyg )
e39454295bbb Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
parents: 582
diff changeset
   269
    $dynano('commentform_message').makeSwitchable();
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   270
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   271
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
   272
window.hideCommentForm = function()
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   273
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   274
  document.getElementById('leave_comment_button').style.display = 'inline';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   275
  document.getElementById('comment_form').style.display = 'none';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   276
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   277
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
   278
window.editComment = function(id, link)
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   279
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   280
  var ctr = document.getElementById('subject_'+id);
102
d807dcd7aed7 [comments] fixed edit button (source wasn't getting filled)
Dan
parents: 86
diff changeset
   281
  var subj = ( ctr.firstChild ) ? trim(ctr.firstChild.nodeValue) : ''; // If there's a span in there that says 'unapproved', this eliminates it
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   282
  ctr.innerHTML = '';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   283
  var ipt = document.createElement('input');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   284
  ipt.id = 'subject_edit_'+id;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   285
  ipt.value = subj;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   286
  ctr.appendChild(ipt);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   287
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   288
  var src = document.getElementById('comment_source_'+id).value;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   289
  var cmt = document.getElementById('comment_'+id);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   290
  cmt.innerHTML = '';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   291
  var ta = document.createElement('textarea');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   292
  ta.rows = '10';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   293
  ta.cols = '40';
541
acb7e23b6ffa Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents: 420
diff changeset
   294
  ta.style.width = '98%';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   295
  ta.value = src;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   296
  ta.id = 'comment_edit_'+id;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   297
  cmt.appendChild(ta);
748
e39454295bbb Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
parents: 582
diff changeset
   298
  $dynano(ta).makeSwitchable();
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   299
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   300
  link.style.fontWeight = 'bold';
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   301
  link.innerHTML = $lang.get('comment_btn_save');
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   302
  link.onclick = function() { var id = this.id.substr(this.id.indexOf('_')+1); saveComment(id, this); return false; };
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   303
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   304
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
   305
window.saveComment = function(id, link)
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   306
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   307
  var data = document.getElementById('comment_edit_'+id).value;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   308
  var subj = document.getElementById('subject_edit_'+id).value;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   309
  var div = document.getElementById('comment_holder_'+id);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   310
  var real_id = div.getElementsByTagName('input')[0]['value'];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   311
  var req = {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   312
    'mode' : 'edit',
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   313
    'id'   : real_id,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   314
    'local_id' : id,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   315
    'data' : data,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   316
    'subj' : subj
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   317
  };
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   318
  link.style.fontWeight = 'normal';
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   319
  link.innerHTML = $lang.get('comment_btn_edit');
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   320
  link.onclick = function() { var id = this.id.substr(this.id.indexOf('_')+1); editComment(id, this); return false; };
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   321
  ajaxComments(req);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   322
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   323
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
   324
window.deleteComment = function(id)
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   325
{
102
d807dcd7aed7 [comments] fixed edit button (source wasn't getting filled)
Dan
parents: 86
diff changeset
   326
  if ( !shift )
d807dcd7aed7 [comments] fixed edit button (source wasn't getting filled)
Dan
parents: 86
diff changeset
   327
  {
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   328
    var c = confirm($lang.get('comment_msg_delete_confirm'));
102
d807dcd7aed7 [comments] fixed edit button (source wasn't getting filled)
Dan
parents: 86
diff changeset
   329
    if(!c)
d807dcd7aed7 [comments] fixed edit button (source wasn't getting filled)
Dan
parents: 86
diff changeset
   330
      return false;
d807dcd7aed7 [comments] fixed edit button (source wasn't getting filled)
Dan
parents: 86
diff changeset
   331
  }
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   332
  var div = document.getElementById('comment_holder_'+id);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   333
  var real_id = div.getElementsByTagName('input')[0]['value'];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   334
  var req = {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   335
    'mode' : 'delete',
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   336
    'id'   : real_id,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   337
    'local_id' : id
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   338
  };
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   339
  ajaxComments(req);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   340
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   341
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
   342
window.submitComment = function()
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   343
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   344
  var name = document.getElementById('commentform_name').value;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   345
  var subj = document.getElementById('commentform_subject').value;
748
e39454295bbb Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
parents: 582
diff changeset
   346
  var text = $dynano('commentform_message').getContent();
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   347
  if ( document.getElementById('commentform_captcha') )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   348
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   349
    var captcha_code = document.getElementById('commentform_captcha').value;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   350
    var captcha_id   = document.getElementById('commentform_captcha_id').value;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   351
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   352
  else
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   353
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   354
    var captcha_code = '';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   355
    var captcha_id   = '';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   356
  }
102
d807dcd7aed7 [comments] fixed edit button (source wasn't getting filled)
Dan
parents: 86
diff changeset
   357
  if ( subj == '' )
d807dcd7aed7 [comments] fixed edit button (source wasn't getting filled)
Dan
parents: 86
diff changeset
   358
  {
748
e39454295bbb Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
parents: 582
diff changeset
   359
    load_component('messagebox');
e39454295bbb Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
parents: 582
diff changeset
   360
    load_component('fadefilter');
550
685e839d934e Added ability to delete the draft revision; [SECURITY] fixed lack of permission check on draft save; renamed messagebox() constructor to MessageBox() (backward compat. maintained)
Dan
parents: 541
diff changeset
   361
    new MessageBox(MB_OK|MB_ICONSTOP, 'Input validation failed', 'Please enter a subject for your comment.');
102
d807dcd7aed7 [comments] fixed edit button (source wasn't getting filled)
Dan
parents: 86
diff changeset
   362
    return false;
d807dcd7aed7 [comments] fixed edit button (source wasn't getting filled)
Dan
parents: 86
diff changeset
   363
  }
d807dcd7aed7 [comments] fixed edit button (source wasn't getting filled)
Dan
parents: 86
diff changeset
   364
  if ( text == '' )
d807dcd7aed7 [comments] fixed edit button (source wasn't getting filled)
Dan
parents: 86
diff changeset
   365
  {
748
e39454295bbb Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
parents: 582
diff changeset
   366
    load_component('messagebox');
e39454295bbb Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
parents: 582
diff changeset
   367
    load_component('fadefilter');
550
685e839d934e Added ability to delete the draft revision; [SECURITY] fixed lack of permission check on draft save; renamed messagebox() constructor to MessageBox() (backward compat. maintained)
Dan
parents: 541
diff changeset
   368
    new MessageBox(MB_OK|MB_ICONSTOP, 'Input validation failed', 'Please enter some text for the body of your comment .');
102
d807dcd7aed7 [comments] fixed edit button (source wasn't getting filled)
Dan
parents: 86
diff changeset
   369
    return false;
d807dcd7aed7 [comments] fixed edit button (source wasn't getting filled)
Dan
parents: 86
diff changeset
   370
  }
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   371
  var req = {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   372
    'mode' : 'submit',
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   373
    'name' : name,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   374
    'subj' : subj,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   375
    'text' : text,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   376
    'captcha_code' : captcha_code,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   377
    'captcha_id'   : captcha_id
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   378
  };
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   379
  ajaxComments(req);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   380
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   381
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
   382
window.redrawComment = function(data)
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   383
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   384
  if ( data.subj )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   385
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   386
    document.getElementById('subject_' + data.id).innerHTML = data.subj;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   387
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   388
  if ( data.approved && data.approved != '1' )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   389
  {
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   390
    document.getElementById('subject_' + data.id).innerHTML += ' <span style="color: #D84308">' + $lang.get('comment_msg_note_unapp') + '</span>';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   391
  }
29
e5484a9e0818 Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents: 1
diff changeset
   392
  if ( data.approved && ( typeof(data.approve_updated) == 'string' && data.approve_updated == 'yes' ) )
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   393
  {
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   394
    var appr = ( data.approved == '1' ) ? $lang.get('comment_btn_mod_unapprove') : $lang.get('comment_btn_mod_approve');
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   395
    document.getElementById('comment_approve_'+data.id).innerHTML = appr;
29
e5484a9e0818 Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents: 1
diff changeset
   396
    
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   397
    if ( data.approved == '1' )
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   398
      comment_decrement_unapproval();
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   399
    else
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   400
      comment_increment_unapproval();
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   401
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   402
  if ( data.text )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   403
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   404
    document.getElementById('comment_' + data.id).innerHTML = data.text;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   405
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   406
  if ( data.src )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   407
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   408
    document.getElementById('comment_source_' + data.id).value = data.src;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   409
  }
359
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   410
  if ( data.ip_addr )
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   411
  {
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 407
diff changeset
   412
    var span = $dynano('comment_ip_' + data.local_id).object;
359
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   413
    if ( !span )
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   414
      return false;
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   415
    span.innerHTML = $lang.get('comment_msg_ip_address') + ' <a href="#rdns" onclick="ajaxReverseDNS(this); return false;">' + data.ip_addr + '</a>';
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   416
  }
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   417
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   418
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
   419
window.approveComment = function(id)
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   420
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   421
  var div = document.getElementById('comment_holder_'+id);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   422
  var real_id = div.getElementsByTagName('input')[0]['value'];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   423
  var req = {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   424
    'mode' : 'approve',
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   425
    'id'   : real_id,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   426
    'local_id' : id
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   427
  };
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   428
  ajaxComments(req);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   429
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   430
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   431
// Does the actual DOM object removal
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
   432
window.annihiliateComment = function(id) // Did I spell that right?
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   433
{
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   434
  var approved = true;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   435
  if(document.getElementById('comment_approve_'+id))
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   436
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   437
    var appr = document.getElementById('comment_approve_'+id).firstChild.nodeValue;
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   438
    if ( appr == $lang.get('comment_btn_mod_approve') )
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   439
    {
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   440
      approved = false;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   441
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   442
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   443
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   444
  var div = document.getElementById('comment_holder_'+id);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   445
  div.parentNode.removeChild(div);
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   446
  
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   447
  // update approval status
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   448
  if ( document.getElementById('comment_count_unapp_inner') && !approved )
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   449
  {
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   450
    comment_decrement_unapproval();
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   451
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   452
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   453
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
   454
window.materializeComment = function(data)
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   455
{
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   456
  // Intelligently get an ID
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   457
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   458
  var i = 0;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   459
  var brother;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   460
  while ( true )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   461
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   462
    var x = document.getElementById('comment_holder_'+i);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   463
    if(!x)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   464
      break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   465
    brother = x;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   466
    i++;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   467
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   468
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   469
  var parser = new templateParser(comment_template);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   470
  var tplvars = new Object();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   471
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   472
  if ( data.approved != '1' && !data.auth_mod_comments )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   473
    return false;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   474
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   475
  tplvars.ID = i;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   476
  tplvars.DATETIME = data.time;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   477
  tplvars.SUBJECT = data.subject;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   478
  tplvars.DATA = data.comment_data;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   479
  tplvars.SIGNATURE = data.signature;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   480
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   481
  tplvars.NAME = data.name;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   482
  if ( data.user_id > 1 )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   483
    tplvars.NAME = '<a href="' + makeUrlNS('User', data.name) + '">' + data.name + '</a>';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   484
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   485
  if ( data.approved != '1' )
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   486
    tplvars.SUBJECT += ' <span style="color: #D84308">' + $lang.get('comment_msg_note_unapp') + '</span>';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   487
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   488
  // User level
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   489
  tplvars.USER_LEVEL = $lang.get('user_type_guest');
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   490
  if ( data.user_level >= data.user_level_list.member ) tplvars.USER_LEVEL = $lang.get('user_type_member');
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   491
  if ( data.user_level >= data.user_level_list.mod ) tplvars.USER_LEVEL = $lang.get('user_type_mod');
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   492
  if ( data.user_level >= data.user_level_list.admin ) tplvars.USER_LEVEL = $lang.get('user_type_admin');
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   493
  
328
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 214
diff changeset
   494
  // Avatar
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 214
diff changeset
   495
  if ( data.user_has_avatar == '1' )
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 214
diff changeset
   496
  {
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 214
diff changeset
   497
    tplvars.AVATAR_URL = scriptPath + '/' + data.avatar_directory + '/' + data.user_id + '.' + data.avatar_type;
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 214
diff changeset
   498
    tplvars.USERPAGE_LINK = makeUrlNS('User', data.name);
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 214
diff changeset
   499
    tplvars.AVATAR_ALT = $lang.get('usercp_avatar_image_alt', { username: data.name });
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 214
diff changeset
   500
  }
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 214
diff changeset
   501
  
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   502
  // Send PM link
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   503
  tplvars.SEND_PM_LINK=(data.user_id>1)?'<a onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/Compose/To/' + ( data.name.replace(/ /g, '_') )) +'">' + $lang.get('comment_btn_send_privmsg') + '</a><br />':'';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   504
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   505
  // Add buddy link
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   506
  tplvars.ADD_BUDDY_LINK=(data.user_id>1)?'<a onclick="window.open(this.href); return false;" href="'+ makeUrlNS('Special', 'PrivateMessages/FriendList/Add/' + ( data.name.replace(/ /g, '_') )) +'">' + $lang.get('comment_btn_add_buddy') + '</a><br />':'';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   507
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   508
  // Edit link
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   509
  tplvars.EDIT_LINK='<a href="#edit_'+i+'" onclick="editComment(\''+i+'\', this); return false;" id="cmteditlink_'+i+'">' + $lang.get('comment_btn_edit') + '</a>';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   510
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   511
  // Delete link
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   512
  tplvars.DELETE_LINK='<a href="#delete_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">' + $lang.get('comment_btn_delete') + '</a>';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   513
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   514
  // Moderation: (Un)approve link
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   515
  var appr = ( data.approved == 1 ) ? $lang.get('comment_btn_mod_unapprove') : $lang.get('comment_btn_mod_approve');
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   516
  tplvars.MOD_APPROVE_LINK='<a href="#approve_'+i+'" id="comment_approve_'+i+'" onclick="approveComment(\''+i+'\'); return false;">'+appr+'</a>';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   517
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   518
  // Moderation: Delete post link
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   519
  tplvars.MOD_DELETE_LINK='<a href="#mod_del_'+i+'" onclick="deleteComment(\''+i+'\'); return false;">' + $lang.get('comment_btn_mod_delete') + '</a>';
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   520
  
359
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   521
  // Moderation: IP address link
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   522
  tplvars.MOD_IP_LINK = '<span id="comment_ip_' + i + '"><a href="#mod_ip_' + i + '" onclick="viewCommentIP(' + data.comment_id + ', ' + i + '); return false;">' + $lang.get('comment_btn_mod_ip_logged') + '</a></span>';
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   523
  
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   524
  var tplbool = new Object();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   525
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   526
  tplbool.signature = ( data.signature == '' ) ? false : true;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   527
  tplbool.can_edit = ( data.auth_edit_comments && ( ( data.user_id == data.user_id && data.logged_in ) || data.auth_mod_comments ) );
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   528
  tplbool.auth_mod = data.auth_mod_comments;
328
dc838fd61a06 Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents: 214
diff changeset
   529
  tplbool.user_has_avatar = ( data.user_has_avatar == '1' );
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   530
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   531
  parser.assign_vars(tplvars);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   532
  parser.assign_bool(tplbool);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   533
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   534
  var div = document.createElement('div');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   535
  div.id = 'comment_holder_'+i;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   536
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   537
  div.innerHTML = '<input type="hidden" value="'+data.comment_id+'" /><input type="hidden" id="comment_source_'+i+'" />' + parser.run();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   538
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   539
  if ( brother )
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   540
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   541
    brother.parentNode.insertBefore(div, brother.nextSibling);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   542
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   543
  else
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   544
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   545
    // No comments in ajaxEditContainer, insert it after the header
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   546
    var aec = document.getElementById("ajaxEditContainer");
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   547
    aec.insertBefore(div, aec.firstChild.nextSibling.nextSibling);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   548
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   549
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   550
  document.getElementById('comment_source_'+i).value = data.comment_source;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   551
  
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   552
  var cnt = document.getElementById('comment_count_inner').innerHTML;
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   553
  cnt = parseInt(cnt);
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   554
  if ( isNaN(cnt) )
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   555
    cnt = 0;
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   556
  
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   557
  var subst = {
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   558
    num_comments: cnt,
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   559
    page_type: ENANO_PAGE_TYPE
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   560
  }
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   561
  
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   562
  var count_msg = ( cnt == 0 ) ? $lang.get('comment_msg_count_zero', subst) : ( ( cnt == 1 ) ? $lang.get('comment_msg_count_one', subst) : $lang.get('comment_msg_count_plural', subst) );
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   563
  
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   564
  document.getElementById('comment_status').firstChild.innerHTML = count_msg;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   565
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   566
  if(document.getElementById('comment_approve_'+i))
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   567
  {
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   568
    var is_unappr = document.getElementById('comment_approve_'+i).firstChild.nodeValue;
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   569
    is_unappr = ( is_unappr == $lang.get('comment_btn_mod_approve') );
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   570
    if ( is_unappr )
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   571
    {
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   572
      comment_increment_unapproval();
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   573
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   574
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   575
  
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   576
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   577
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
   578
window.comment_decrement_unapproval = function()
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   579
{
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   580
  if ( document.getElementById('comment_count_unapp_inner') )
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   581
  {
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   582
    var num_unapp = parseInt(document.getElementById('comment_count_unapp_inner').innerHTML);
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   583
    if ( !isNaN(num_unapp) )
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   584
    {
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   585
      num_unapp = num_unapp - 1;
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   586
      if ( num_unapp == 0 )
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   587
      {
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   588
        var p = document.getElementById('comment_status');
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   589
        p.removeChild(p.childNodes[2]);
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   590
        p.removeChild(p.childNodes[1]);
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   591
      }
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   592
      else
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   593
      {
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   594
        var count_msg = $lang.get('comment_msg_count_unapp_mod', { num_unapp: num_unapp });
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   595
        document.getElementById('comment_count_unapp_inner').parentNode.innerHTML = count_msg;
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   596
      }
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   597
    }
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   598
  }
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   599
}
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   600
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
   601
window.comment_increment_unapproval = function()
212
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   602
{
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   603
  if ( document.getElementById('comment_count_unapp_inner') )
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   604
  {
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   605
    var num_unapp = parseInt(document.getElementById('comment_count_unapp_inner').innerHTML);
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   606
    if ( isNaN(num_unapp) )
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   607
      num_unapp = 0;
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   608
    num_unapp = num_unapp + 1;
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   609
    var count_msg = $lang.get('comment_msg_count_unapp_mod', { num_unapp: num_unapp });
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   610
    document.getElementById('comment_count_unapp_inner').parentNode.innerHTML = count_msg;
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   611
  }
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   612
  else
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   613
  {
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   614
    var count_msg = $lang.get('comment_msg_count_unapp_mod', { num_unapp: 1 });
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   615
    var status = document.getElementById('comment_status');
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   616
    if ( !status.childNodes[1] )
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   617
      status.appendChild(document.createTextNode(' '));
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   618
    var span = document.createElement('span');
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   619
    span.id = 'comment_status_unapp';
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   620
    span.style.color = '#D84308';
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   621
    span.innerHTML = count_msg;
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   622
    status.appendChild(span);
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   623
  }
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   624
}
30b857a6b811 Reworked comment system to not use HACKISH FIXES; AJAX comment framework is completely localized now
Dan
parents: 108
diff changeset
   625
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
   626
window.viewCommentIP = function(id, local_id)
359
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   627
{
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   628
  // set "loading" indicator on IP button
420
301f546688d1 Re-enabled, debugged, and optimized Javascript compression code
Dan
parents: 407
diff changeset
   629
  var span = $dynano('comment_ip_' + local_id).object;
359
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   630
  if ( !span )
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   631
    return false;
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   632
  span.innerHTML = '<img alt="..." src="' + ajax_load_icon + '" />';
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   633
  
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   634
  var parms = {
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   635
    mode: 'view_ip',
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   636
    id: id,
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   637
    local_id: local_id
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   638
  }
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   639
  ajaxComments(parms);
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   640
}
e0787bb6285b Implemented IP logging for comments and registration
Dan
parents: 328
diff changeset
   641