Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Cmd-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (Cmd-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Clear the cache in Tools → Preferences

For details and instructions about other browsers, see Wikipedia:Bypass your cache.

//adapted from http://olivier.thill.perso.neuf.fr/russian/lcg.htm by en:ws:User:Rene1596
charsets = [["Latin", [[0x41, 0x5A], [0x61, 0x7A], [0xC0, 0xFF]], "lightyellow"], ["Greek", [[0x370, 0x3E1]], "lightcyan"], ["Cyrillic", [[0x400, 0x46F]], "lightgreen"], ["Other", [], "white"]];

function show_text_in_color(from)
{
  var from_lg = from.length; 
  var to = new String();
  var c;
  var typ, old_typ;

  to = "";
  old_typ = "?";
  for(i=0; i < from_lg; i++) {
    c = from.charAt(i, 1);
    n = from.charCodeAt(i, 1);
    typ = "Other"
    for(j=0; j < charsets.length; j++) {
      for(k=0; k < charsets[j][1].length; k++) {
        if (n >= charsets[j][1][k][0] && n <= charsets[j][1][k][1]) typ = charsets[j][0]
      }
    }
    
    if (typ != old_typ) {
      if (old_typ != "?") to += "</span>";
      for(j=0; j < charsets.length; j++) {
        if (typ == charsets[j][0]) to += "<span style='background-color: " + charsets[j][2] + ";'>";
      }
      old_typ = typ;
    }
    to += c;
    if (c == '\n') to += "<br>";
  }
  if (old_typ != "?") to += "</span>";

  return to;
}

function charset_dialog_header() {
  h = "<p>"
  for (i=0; i < charsets.length; i++) {
    h += "<span style='background-color: " + charsets[i][2] + ";'>" + charsets[i][0] + "</span>, ";
  }
  h = h.substr(0, h.length-2);
  h += "</p><hr /><div id='disambiguated-text'></div>";
  return h;
}


// add button -- cribbed from http://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization
if ( typeof $j != 'undefined' && typeof $.fn.wikiEditor != 'undefined' ) {
  // To add a button to an existing toolbar group:
  $(document).ready( function() {
    $( '#wpTextbox1' ).wikiEditor( 'addDialog', {
      'charset-disambig-dialog': {
        resizeme: false,
        titleMsg: 'charset-disambig-dialog',
        id: 'charset-disambig-dialog',
        init: function() {},
        html: charset_dialog_header(),
        dialog: {
          width: 550,
          open: function () { document.getElementById("disambiguated-text").innerHTML = show_text_in_color(document.getElementById("wpTextbox1").value); },
          beforeclose: function () {},
          buttons: {}
        }
      }
    });
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
      'section': 'main',
      'group': 'insert',
      'tools': {
        'charsetdisambig': {
          label: 'Disambiguate character sets', // or use labelMsg for a localized label, see above
          type: 'button',
          icon: '//upload.wikimedia.org/wikipedia/commons/3/3e/Disambiguate_charset_button.png',
          action: {
            type: 'dialog',
            module: 'charset-disambig-dialog'
          }
        }
      }
    });
  });
}