User:Connel MacKenzie/irc.js

From Wiktionary, the free dictionary
Jump to navigation Jump to search

Note – after saving, it will take 5-10 minutes before the changes take effect. You may also have to bypass your browser’s cache to see the changes.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

/* Use Wikizine.org's CGI-IRC gateway
   May have to install my own copy of http://cgiirc.sourceforge.net/ on toolserver?
*/

function wiktOpenCgiWindow() {
 // If they have a "delete" button on ''this'' page, they are a sysop.
// var isSysop = document.getElementById('ca-delete');
// if ( !isSysop ) return;
        PromptWin = window.open("about:blank", "WiktionaryIRC", "width=680,location=yes,menubar=yes,toolbar=yes,resizable,scrollbars");
        PromptWin.document.open();
        PromptWin.document.write("<html><title>Wiktionary IRC on irc.freenode.net</title>");
        PromptWin.document.write('<body onload="document.loginform.submit.click();">');
        PromptWin.document.write('<form action="http://chatwikizine.memebot.com/cgi-bin/cgiirc/irc.cgi" method="post" id="loginform" name="loginform">');
        PromptWin.document.write('<input type="hidden" name="interface" value="nonjs">');
        PromptWin.document.write('<input type="text" name="Nickname" value="' + wgUserName + '">');
        PromptWin.document.write('<input type="text" name="Server" value="irc.freenode.net " disabled="1">');
        PromptWin.document.write('<select name="Channel"><option value="#wiktionary">#wiktionary</option></select>');
        PromptWin.document.write('<input type="submit" name="submit" id="submit">');
        PromptWin.document.write('</form></body></html>');
        PromptWin.document.close();
}

function wiktAddIrcButton() {
 // If they have a "delete" button on ''this'' page, they are a sysop.
 var isSysop = document.getElementById('ca-delete');
 if ( !isSysop ) return;
 var irca = document.createElement('a');
     irca.href = "javascript:wiktOpenCgiWindow(); return false;";
     irca.onclick = function() { wiktOpenCgiWindow(); return false;} ;
 var ircs = document.createTextNode(' .  . ');
 var irct = document.createTextNode('irc');
     irca.appendChild( irct );
 document.getElementById( 'pt-logout' ).parentNode.appendChild( ircs );
 document.getElementById( 'pt-logout' ).parentNode.appendChild( irca );
}

$( wiktAddIrcButton );