MediaWiki:Common.js: Difference between revisions

do you not like let
(WHY IS THE JAVASCRIPT PARSER 6 YEARS OLD - in other news, I fixed it)
(do you not like let)
 
(5 intermediate revisions by the same user not shown)
Line 21: Line 21:
       $('.tooltip').remove();
       $('.tooltip').remove();
     }).mousemove(
     }).mousemove(
       function (e) {
       function(e) {
         var mousex = e.pageX + 20; //Get X coordinates
         var mousex = e.pageX + 20;
         var mousey = e.pageY - 40; //Get Y coordinates
         var mousey = e.pageY - 40;
         $('.tooltip').css({
         var tooltip = $('.tooltip');
        if (mousex + tooltip.width() >= $(window).width()) mousex -= tooltip.width() + 40;
        tooltip.css({
           top: mousey,
           top: mousey,
           left: mousex,
           left: mousex,
Line 44: Line 46:
   });
   });


  //Code for Cycling
  $('.cyclist > :not(:first-child)').hide();
  setInterval(function() {
    if (!!$('.cyclist').filter(function() { return $(this).is(":hover"); }).length) return;
    $('.cyclist > :not(:hidden)').hide().each(function() {
      var elem = $(this);
      elem.next().show();
      if (elem.is(':last-child')) elem.siblings().first().show();
    });
  }, 2000);
});
});


Line 50: Line 63:
   var res = '';
   var res = '';
   for (var i = 0; i < text.length; i++) {
   for (var i = 0; i < text.length; i++) {
     if ((text[i] == '&') && /[0-9a-fl-or]/.test(text[i + 1])) continue;
     if (text[i] == '\\') {
     else if (text[i] == '/') {
      res += text[i+1];
      i++;
    } else if (/&[0-9a-fl-o]/.test(text.substring(i,i+2))) {
      res += '<span class="format-' + text[i+1] + '">';
      spans++;
      i++;
    } else if (text.substring(i,i+2) == '&r') {
      res += '</span>'.repeat(spans);
      spans = 0;
      i++;
    } else if (/&#[0-9A-Fa-f]{6}/.test(text.substring(i,i+8))) {
      res += '<span style="color: ' + text.substring(i+1,i+8) + '">';
      spans++;
      i += 7;
     } else if (text[i] == '/') {
       res += '<br>';
       res += '<br>';
       continue;
    } else {
       res += text[i];
     }
     }
    else if ((text[i - 1] == '&') && /[0-9a-fl-or]/.test(text[i])) {
      if (text[i] == 'r') {
        res += '</span>'.repeat(spans);
        spans = 0;
      } else {
        res += '<span class="format-' + text[i] + '">';
        spans++;
      }
    } else res += text[i];
   }
   }
   return res + '</span>'.repeat(spans);
   return res + '</span>'.repeat(spans);
}
}
184

edits