میدیاویکی:Gadget-irc.js

لە ئینسایکڵۆپیدیای ئازادی ویکیپیدیاوە
تێبینی: دوای پاشەکەوتکردن، پێویستە کاشی وێبگەڕەکەت پاک بکەیتەوە تا گۆڕانکارییەکان ببینیت. بۆ گووگڵ کڕۆم، فایەرفۆکس، مایکرۆسۆفت ئێج و سافاری: پەنجە لەسەر دوگمەی ⇧ Shift ڕاگرە و کرتە لەسەر Reload بکە. بۆ وردەکاری و ڕێنمایییەکان لەسەر وێبگەڕەکانی تر، بڕوانە ئێرە.
//[[ویکیپیدیا:کەناڵی مشتومڕ/زیندوو]]
/* This is the script to add CGI:IRC login box to random pages (like [[WN:IRC]]). Please report problems to [[m:n:user talk:Bawolff]] (http://en.wikinews.org/wiki/user_talk:Bawolff ). modifications may take some time to get through caching. For yourself you can do a hard refresh of  [{{SERVER}}/w/index.php?title=Mediawiki:Irc.js&action=raw&ctype=text/javascript this page] to make mods go live. From http://en.wikinews.org/wiki/mediawiki:Irc.js this is version 2.0. If you have any complaints, comments requests, please contact me at http://en.wikinews.org/wiki/user_talk:Bawolff
**Just add <code><nowiki><div id="cgiircbox"/> </nowiki></code> (some wikis may need <code><nowiki><div id="cgiircbox"></div> </nowiki></code>) to a random page. You can style and add classes to thsi div if you want. in fact it doesn' even have to be a div, but a block level element is recommended (could be <code><nowiki><center id="cgiircbox"/> </nowiki></code>)
**Note: This is heavily based on the login page from CGI:IRC 0.5 (or more specificly it is a reimplementation of the login page in javascript, to get arround restrictions on which elements can be added to a mediawiki page, plus a few extra features added along the way). CGI:IRC is made by David Leadbeater and is under the GPL. See http://cgiirc.sf.net . (therefor i geuss you could consider the entire combined thing under the gpl. I'm not a 100% sure how the copyright issue for this works, in any case I'm ok with any of my edits to the script being GPL)
*/
 
/*extern wgUserName wgUserGroups, new_input, new_element, new_label, setcharset*/
function add_irc() {
    var debug = false; 
    var irc_div = document.getElementById("cgiircbox");
    if (irc_div) {
        var ircframe = document.createElement("iframe");        
        var src_attr = document.createAttribute("src");
        var dim = new Array(document.createAttribute("width"), document.createAttribute("height"));
        src_attr.nodeValue = "//webchat.freenode.net/?channels=%23wikipedia-ckb&uio=MT1mYWxzZQ9a&prompt=1&nick=" + (mw.config.get('wgUserName') || '');
        dim[0].nodeValue = "100%"; 
        dim[1].nodeValue = "500";
        ircframe.setAttributeNode(src_attr);
        ircframe.setAttributeNode(dim[0]);
        ircframe.setAttributeNode(dim[1]);
        irc_div.appendChild(ircframe);
 
    }
}
//because this is already from a load event
add_irc();