Dotclear


Ignore:
Timestamp:
09/17/18 16:46:35 (7 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Harmonize scripts used to display entries/comments/trackbacks content in lists - Spam content is displayed as HTML code only, meta key may be used to display other content HTML code (meta key = cmd key on MacOS, windows key on Windows, ...) - Server errors are now basically reported (more info in console log, as timeout, offline, …) to the user

File:
1 edited

Legend:

Unmodified
Added
Removed
  • admin/js/_post.js

    r3706 r3878  
    22'use strict'; 
    33 
    4 dotclear.viewCommentContent = function(line) { 
     4dotclear.viewCommentContent = function(line, action, e) { 
     5  action = action || 'toggle'; 
     6  if ($(line).attr('id') == undefined) { 
     7    return; 
     8  } 
     9 
    510  var commentId = $(line).attr('id').substr(1); 
    611  var tr = document.getElementById('ce' + commentId); 
     12  var spam = (e.metaKey || $(line).hasClass('sts-junk')); 
    713 
    814  if (!tr) { 
    9     tr = document.createElement('tr'); 
    10     tr.id = 'ce' + commentId; 
    11     var td = document.createElement('td'); 
    12     td.colSpan = 6; 
    13     td.className = 'expand'; 
    14     tr.appendChild(td); 
    15  
    1615    // Get comment content 
    17     $.get('services.php', { 
    18       f: 'getCommentById', 
    19       id: commentId 
    20     }, function(data) { 
    21       var rsp = $(data).children('rsp')[0]; 
    22  
    23       if (rsp.attributes[0].value == 'ok') { 
    24         var comment = $(rsp).find('comment_display_content').text(); 
    25  
    26         if (comment) { 
    27           $(td).append(comment); 
    28           var comment_email = $(rsp).find('comment_email').text(); 
    29           var comment_site = $(rsp).find('comment_site').text(); 
    30           //          var comment_ip = $(rsp).find('comment_ip').text(); 
    31           var comment_spam_disp = $(rsp).find('comment_spam_disp').text(); 
    32  
    33           $(td).append('<p><strong>' + dotclear.msg.website + 
    34             '</strong> ' + comment_site + '<br />' + 
    35             '<strong>' + dotclear.msg.email + '</strong> ' + 
    36             comment_email + '<br />' + comment_spam_disp + '</p>'); 
    37         } 
     16    dotclear.getCommentContent(commentId, function(content) { 
     17      if (content) { 
     18        // Content found 
     19        tr = document.createElement('tr'); 
     20        tr.id = 'ce' + commentId; 
     21        var td = document.createElement('td'); 
     22        td.colSpan = $(line).children('td').length; 
     23        td.className = 'expand'; 
     24        tr.appendChild(td); 
     25        $(td).append(content); 
     26        $(line).addClass('expand'); 
     27        line.parentNode.insertBefore(tr, line.nextSibling); 
    3828      } else { 
    39         window.alert($(rsp).find('message').text()); 
     29        // No content, content not found or server error 
     30        $(line).removeClass('expand'); 
    4031      } 
     32    }, { 
     33      ip: false, 
     34      clean: spam 
    4135    }); 
    42  
    43     $(line).toggleClass('expand'); 
    44     line.parentNode.insertBefore(tr, line.nextSibling); 
    45   } else if (tr.style.display == 'none') { 
    46     $(tr).toggle(); 
    47     $(line).toggleClass('expand'); 
    4836  } else { 
    4937    $(tr).toggle(); 
     
    164152  $('#comments').onetabload(function() { 
    165153    $.expandContent({ 
     154      line: $('#form-comments .comments-list tr:not(.line)'), 
    166155      lines: $('#form-comments .comments-list tr.line'), 
    167156      callback: dotclear.viewCommentContent 
     
    176165  $('#trackbacks').onetabload(function() { 
    177166    $.expandContent({ 
     167      line: $('#form-trackbacks .comments-list tr:not(.line)'), 
    178168      lines: $('#form-trackbacks .comments-list tr.line'), 
    179169      callback: dotclear.viewCommentContent 
Note: See TracChangeset for help on using the changeset viewer.

Sites map