Plugin Directory

Changeset 2361537


Ignore:
Timestamp:
08/14/2020 11:39:13 PM (6 years ago)
Author:
jwz
Message:

Version 1.4

Location:
herp-derp
Files:
2 edited
4 copied

Legend:

Unmodified
Added
Removed
  • herp-derp/tags/1.4/herpderp.js

    r1988477 r2361537  
    11/* Herp all the derps.
    22
    3    Copyright © 2012-2018 Jamie Zawinski <jwz@jwz.org>
     3   Copyright © 2012-2019 Jamie Zawinski <jwz@jwz.org>
    44
    55   Permission to use, copy, modify, distribute, and sell this software and its
     
    2525 */
    2626
    27 function derp(pp, herpa) {
    28   var aa = pp.getElementsByTagName('p');
    29   for (var i = 0; i < aa.length; i++) {
    30     var p = aa[i];
    31     if (! p.herp) {
    32       p.herp = p.innerHTML;
    33       p.derp = p.innerHTML;
    34       p.derp = p.derp.replace (/\n/gi, " ");
    35       p.derp = p.derp.replace (/<BR *\/?>/gi, "\n");
    36       p.derp = p.derp.replace (/<P\b[^<>]*>/gi, "\n\n");
    37       p.derp = p.derp.replace (/<[^<>]*>/gi, "");
    38       p.derp = p.derp.replace (/[:.]([^\s])/gi, '$1');
    39       p.derp = p.derp.replace (/([^-.!?,;:\"()\s]+)/gi,
    40           function (s) {
    41             var hd = ['herp', 'HERP', 'Herp',
    42                       'derp', 'DERP', 'Derp'];
    43             var j;
    44             if (s == s.toLowerCase()) j = 0;
    45             else if (s.length > 1 && s == s.toUpperCase()) j = 1;
    46             else j = 2;
    47             if (Math.random() > 0.5) j += 3;
    48             return hd[j];
    49           });
    50       p.derp = p.derp.replace (/\n/g, "<BR>");
     27function derp(p, herpa) {
     28  if (! p.herp) {
     29    p.herp = p.innerHTML;
     30    var aa = p.herp.match (/(<[^<>]*>|[^<>]+)/g);
     31    for (var i = 0; i < aa.length; i++) {
     32      if (aa[i].match(/^</)) continue;
     33      aa[i] = aa[i].replace (/&#?[a-z\d]+;/gi, '_');
     34      aa[i] = aa[i].replace (/([^-.!?,;:\"()\s]+)/gi,
     35        function (s) {
     36          var hd = ['herp', 'HERP', 'Herp',
     37                    'derp', 'DERP', 'Derp'];
     38          var j;
     39          if (s == s.toLowerCase()) j = 0;
     40          else if (s.length > 1 && s == s.toUpperCase()) j = 1;
     41          else j = 2;
     42          if (Math.random() > 0.5) j += 3;
     43          return hd[j];
     44        });
    5145    }
    52     p.innerHTML = (herpa ? p.herp : p.derp);
    53     p.onclick = herpclerk;
     46    p.derp = aa.join('');
    5447  }
     48  p.innerHTML = (herpa ? p.herp : p.derp);
     49  p.parentNode.onclick = herpclerk;
    5550}
    5651
    5752function herpclerk(e) {
    58   var p = e.target;
    59   derp (p.parentNode, p.herp != p.innerHTML);
     53  var p = e.currentTarget || e.originalTarget || e.target;
     54  var aa = Array.from (p.getElementsByTagName('span'));
     55  aa.push(p);
     56  for (var i = 0; i < aa.length; i++) {
     57    if (aa[i].className.match (/\bherpc\b/)) {
     58      derp (aa[i], aa[i].herp !== aa[i].innerHTML);
     59    }
     60  }
    6061  return false;
    6162}
     
    6970  }
    7071  if (! derpa) {
    71     var aa = document.getElementsByTagName('p');
     72    var aa = document.getElementsByTagName('span');
    7273    for (var i = 0; i < aa.length; i++) {
    73       if (aa[i].onclick == herpclerk)
    74         aa[i].onclick = null;
     74      if (aa[i].parentNode.onclick == herpclerk) {
     75        aa[i].parentNode.onclick = null;
     76      }
    7577    }
    7678  }
  • herp-derp/tags/1.4/herpderp.php

    r1988477 r2361537  
    33Plugin Name: Herp Derp
    44Plugin URI: https://www.jwz.org/herpderp/
    5 Version: 1.3
     5Version: 1.4
    66Description: This plugin adds a checkbox to replace the text of your comments with "Herp Derp".
    77Author: Jamie Zawinski
  • herp-derp/trunk/herpderp.js

    r1988477 r2361537  
    11/* Herp all the derps.
    22
    3    Copyright © 2012-2018 Jamie Zawinski <jwz@jwz.org>
     3   Copyright © 2012-2019 Jamie Zawinski <jwz@jwz.org>
    44
    55   Permission to use, copy, modify, distribute, and sell this software and its
     
    2525 */
    2626
    27 function derp(pp, herpa) {
    28   var aa = pp.getElementsByTagName('p');
    29   for (var i = 0; i < aa.length; i++) {
    30     var p = aa[i];
    31     if (! p.herp) {
    32       p.herp = p.innerHTML;
    33       p.derp = p.innerHTML;
    34       p.derp = p.derp.replace (/\n/gi, " ");
    35       p.derp = p.derp.replace (/<BR *\/?>/gi, "\n");
    36       p.derp = p.derp.replace (/<P\b[^<>]*>/gi, "\n\n");
    37       p.derp = p.derp.replace (/<[^<>]*>/gi, "");
    38       p.derp = p.derp.replace (/[:.]([^\s])/gi, '$1');
    39       p.derp = p.derp.replace (/([^-.!?,;:\"()\s]+)/gi,
    40           function (s) {
    41             var hd = ['herp', 'HERP', 'Herp',
    42                       'derp', 'DERP', 'Derp'];
    43             var j;
    44             if (s == s.toLowerCase()) j = 0;
    45             else if (s.length > 1 && s == s.toUpperCase()) j = 1;
    46             else j = 2;
    47             if (Math.random() > 0.5) j += 3;
    48             return hd[j];
    49           });
    50       p.derp = p.derp.replace (/\n/g, "<BR>");
     27function derp(p, herpa) {
     28  if (! p.herp) {
     29    p.herp = p.innerHTML;
     30    var aa = p.herp.match (/(<[^<>]*>|[^<>]+)/g);
     31    for (var i = 0; i < aa.length; i++) {
     32      if (aa[i].match(/^</)) continue;
     33      aa[i] = aa[i].replace (/&#?[a-z\d]+;/gi, '_');
     34      aa[i] = aa[i].replace (/([^-.!?,;:\"()\s]+)/gi,
     35        function (s) {
     36          var hd = ['herp', 'HERP', 'Herp',
     37                    'derp', 'DERP', 'Derp'];
     38          var j;
     39          if (s == s.toLowerCase()) j = 0;
     40          else if (s.length > 1 && s == s.toUpperCase()) j = 1;
     41          else j = 2;
     42          if (Math.random() > 0.5) j += 3;
     43          return hd[j];
     44        });
    5145    }
    52     p.innerHTML = (herpa ? p.herp : p.derp);
    53     p.onclick = herpclerk;
     46    p.derp = aa.join('');
    5447  }
     48  p.innerHTML = (herpa ? p.herp : p.derp);
     49  p.parentNode.onclick = herpclerk;
    5550}
    5651
    5752function herpclerk(e) {
    58   var p = e.target;
    59   derp (p.parentNode, p.herp != p.innerHTML);
     53  var p = e.currentTarget || e.originalTarget || e.target;
     54  var aa = Array.from (p.getElementsByTagName('span'));
     55  aa.push(p);
     56  for (var i = 0; i < aa.length; i++) {
     57    if (aa[i].className.match (/\bherpc\b/)) {
     58      derp (aa[i], aa[i].herp !== aa[i].innerHTML);
     59    }
     60  }
    6061  return false;
    6162}
     
    6970  }
    7071  if (! derpa) {
    71     var aa = document.getElementsByTagName('p');
     72    var aa = document.getElementsByTagName('span');
    7273    for (var i = 0; i < aa.length; i++) {
    73       if (aa[i].onclick == herpclerk)
    74         aa[i].onclick = null;
     74      if (aa[i].parentNode.onclick == herpclerk) {
     75        aa[i].parentNode.onclick = null;
     76      }
    7577    }
    7678  }
  • herp-derp/trunk/herpderp.php

    r1988477 r2361537  
    33Plugin Name: Herp Derp
    44Plugin URI: https://www.jwz.org/herpderp/
    5 Version: 1.3
     5Version: 1.4
    66Description: This plugin adds a checkbox to replace the text of your comments with "Herp Derp".
    77Author: Jamie Zawinski
Note: See TracChangeset for help on using the changeset viewer.