Dotclear


Ignore:
Timestamp:
09/18/18 20:22:10 (7 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Use let and const rather than var (ES2015/ES6), use template string where is more efficient

Location:
plugins/tags/js
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • plugins/tags/js/ckeditor-tags-plugin.js

    r3709 r3880  
    88        exec: function(editor) { 
    99          if (editor.getSelection().getNative().toString().replace(/\s*/, '') != '') { 
    10             var str = editor.getSelection().getNative().toString().replace(/\s*/, ''); 
    11             var url = dotclear.msg.tag_url; 
     10            const str = editor.getSelection().getNative().toString().replace(/\s*/, ''); 
     11            const url = dotclear.msg.tag_url; 
    1212            window.dc_tag_editor.addMeta(str); 
    13             var link = '<a href="' + $.stripBaseURL(url + '/' + str) + '">' + str + '</a>'; 
    14             var element = CKEDITOR.dom.element.createFromHtml(link); 
     13            const link = `<a href="${$.stripBaseURL(url + '/' + str)}">${str}</a>`; 
     14            const element = CKEDITOR.dom.element.createFromHtml(link); 
    1515            editor.insertElement(element); 
    1616          } 
  • plugins/tags/js/legacy-post.js

    r3709 r3880  
    3535}; 
    3636jsToolBar.prototype.elements.tag.fn.markdown = function() { 
    37   var url = this.elements.tag.url; 
     37  const url = this.elements.tag.url; 
    3838  this.encloseSelection('', '', function(str) { 
    3939    if (str == '') { 
     
    5050}; 
    5151jsToolBar.prototype.elements.tag.fn.xhtml = function() { 
    52   var url = this.elements.tag.url; 
     52  const url = this.elements.tag.url; 
    5353  this.encloseSelection('', '', function(str) { 
    5454    if (str == '') { 
     
    6565}; 
    6666jsToolBar.prototype.elements.tag.fn.wysiwyg = function() { 
    67   var t = this.getSelectedText(); 
     67  const t = this.getSelectedText(); 
    6868 
    6969  if (t == '') { 
     
    7575  } 
    7676 
    77   var n = this.getSelectedNode(); 
    78   var a = document.createElement('a'); 
     77  const n = this.getSelectedNode(); 
     78  const a = document.createElement('a'); 
    7979  a.href = this.stripBaseURL(this.elements.tag.url + '/' + t); 
    8080  a.appendChild(n); 
  • plugins/tags/js/post.js

    r3709 r3880  
    44$(function() { 
    55  $('#edit-entry').onetabload(function() { 
    6     var tags_edit = $('#tags-edit'); 
    7     var post_id = $('#id'); 
    8     var meta_field = null; 
    9     var mEdit = null; 
     6    const tags_edit = $('#tags-edit'); 
     7    let post_id = $('#id'); 
     8    let meta_field = null; 
     9    let mEdit = null; 
    1010 
    1111    if (tags_edit.length > 0) { 
     
    3434      matchContains: true, 
    3535      parse: function(xml) { 
    36         var results = []; 
     36        let results = []; 
    3737        $(xml).find('meta').each(function() { 
    3838          results[results.length] = { 
  • plugins/tags/js/posts_actions.js

    r3709 r3880  
    33 
    44$(function() { 
    5      var tag_field = $('#new_tags'); 
     5  const tag_field = $('#new_tags'); 
    66 
    7      tag_field.after('<div id="tags_list"></div>'); 
    8      tag_field.hide(); 
     7  tag_field.after('<div id="tags_list"></div>'); 
     8  tag_field.hide(); 
    99 
    10      var target = $('#tags_list'); 
    11      var mEdit = new metaEditor(target,tag_field,'tag',editor_tags_options); 
    12      mEdit.meta_url = 'plugin.php?p=tags&m=tag_posts&amp;tag='; 
     10  const target = $('#tags_list'); 
     11  let mEdit = new metaEditor(target, tag_field, 'tag', editor_tags_options); 
     12  mEdit.meta_url = 'plugin.php?p=tags&m=tag_posts&amp;tag='; 
    1313 
    14      mEdit.meta_dialog = $('<input type="text" />'); 
    15      mEdit.meta_dialog.attr('title',mEdit.text_add_meta.replace(/%s/,mEdit.meta_type)); 
    16      mEdit.meta_dialog.attr('id','post_meta_input'); 
    17      mEdit.meta_dialog.css('width','90%'); 
     14  mEdit.meta_dialog = $('<input type="text" />'); 
     15  mEdit.meta_dialog.attr('title', mEdit.text_add_meta.replace(/%s/, mEdit.meta_type)); 
     16  mEdit.meta_dialog.attr('id', 'post_meta_input'); 
     17  mEdit.meta_dialog.css('width', '90%'); 
    1818 
    19      mEdit.addMetaDialog(); 
     19  mEdit.addMetaDialog(); 
    2020 
    21      $('input[name="save_tags"]').click(function() { 
    22           tag_field.val($('#post_meta_input').val()); 
    23      }); 
     21  $('input[name="save_tags"]').click(function() { 
     22    tag_field.val($('#post_meta_input').val()); 
     23  }); 
    2424 
    25      $('#post_meta_input').autocomplete(mEdit.service_uri, { 
    26           extraParams: { 
    27                'f':        'searchMeta', 
    28                'metaType': 'tag' 
    29           }, 
    30           delay: 1000, 
    31           multiple: true, 
    32           matchSubset: false, 
    33           matchContains: true, 
    34           parse: function(xml) { 
    35                var results = []; 
    36                $(xml).find('meta').each(function(){ 
    37                     results[results.length] = { 
    38                          data: { 
    39                               'id':      $(this).text(), 
    40                               'count':  $(this).attr('count'), 
    41                               'percent': $(this).attr('roundpercent') 
    42                          }, 
    43                          result: $(this).text() 
    44                     }; 
    45                }); 
    46                return results; 
    47           }, 
    48           formatItem: function(tag) { 
    49                return tag.id + ' <em>(' + 
    50                dotclear.msg.tags_autocomplete. 
    51                     replace('%p',tag.percent). 
    52                     replace('%e',tag.count + ' ' + 
    53                          (tag.count > 1 ? 
    54                          dotclear.msg.entries : 
    55                          dotclear.msg.entry) 
    56                     ) + 
    57                ')</em>'; 
    58           }, 
    59           formatResult: function(tag) { 
    60                return tag.result; 
    61           } 
    62      }); 
     25  $('#post_meta_input').autocomplete(mEdit.service_uri, { 
     26    extraParams: { 
     27      'f': 'searchMeta', 
     28      'metaType': 'tag' 
     29    }, 
     30    delay: 1000, 
     31    multiple: true, 
     32    matchSubset: false, 
     33    matchContains: true, 
     34    parse: function(xml) { 
     35      let results = []; 
     36      $(xml).find('meta').each(function() { 
     37        results[results.length] = { 
     38          data: { 
     39            'id': $(this).text(), 
     40            'count': $(this).attr('count'), 
     41            'percent': $(this).attr('roundpercent') 
     42          }, 
     43          result: $(this).text() 
     44        }; 
     45      }); 
     46      return results; 
     47    }, 
     48    formatItem: function(tag) { 
     49      return tag.id + ' <em>(' + 
     50        dotclear.msg.tags_autocomplete. 
     51      replace('%p', tag.percent). 
     52      replace('%e', tag.count + ' ' + 
     53          (tag.count > 1 ? 
     54            dotclear.msg.entries : 
     55            dotclear.msg.entry) 
     56        ) + 
     57        ')</em>'; 
     58    }, 
     59    formatResult: function(tag) { 
     60      return tag.result; 
     61    } 
     62  }); 
    6363}); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map