Forum:I need a Common.js code!

I would like to add a feature to my wikia that automatically refreshes the page being viewed either constantly, or every few minutes or so. Can anyone post a code that can be added to MediaWiki:Common.js that would do such a thing?--  Chris  talk   blog  20:34, August 2, 2010 (UTC)
 * I don't think you should add that to the whole wiki, but maybe for yourself. -- Jeffwang16  (Talk)   (Contributions)   (Email me!)  20:58, August 2, 2010 (UTC)
 * You could use AjaxRC. —Manyman (talk) 21:01, August 2, 2010 (UTC)
 * The are also Browsers additions/plug-ins that do the same thing. without annoying user who don't want the pages refreshing. Perhaps an addtion to the wiki's community page with recommendations to them? -- 21:49, August 2, 2010 (UTC)

I checked out the AjaxRC page, Manyman, but I am new to Javascript or whatever it is called and don't really understand exactly what coding to enter. Can you please just post the full code for that here please. --  Chris  talk   blog  00:52, August 3, 2010 (UTC)

Wait, would this work?--  Chris  talk   blog  01:10, August 3, 2010 (UTC)

/* Enables AjaxRC (Advanced auto refreshing recent changes and watchlist) */ importScriptPage('AjaxRC/code.js', 'dev'); var indicator = 'http://images3.wikia.nocookie.net/__cb20100617104236/dev/images/d/de/Ajax'; /* End of the AjaxRC replacement */


 * It should be this if it was right I'm not good either but I know for sure one thing is wrong.


 * /* Enables AjaxRC (Advanced auto refreshing recent changes and watchlist) */
 * importScriptPage('AjaxRC/code.js', 'dev');
 * var indicator = 'http://images3.wikia.nocookie.net/dev/images/d/de/Ajax';
 * /* End of the AjaxRC replacement */
 * Done?
 * -- Jeffwang16  (Talk)   (Contributions)   (Email me!)  01:24, August 3, 2010 (UTC)
 * -- Jeffwang16  (Talk)   (Contributions)   (Email me!)  01:24, August 3, 2010 (UTC)
 * -- Jeffwang16  (Talk)   (Contributions)   (Email me!)  01:24, August 3, 2010 (UTC)

How do I know if it is working properly? --  Chris  talk   blog  01:27, August 3, 2010 (UTC)


 * Good question! Go to the Admin Tools Wiki (a test wiki) by clicking here. -- Jeffwang16  (Talk)   (Contributions)   (Email me!)  02:39, August 3, 2010 (UTC)
 * It should be

importScriptPage('AjaxRC/code.js', 'dev'); ajaxPages = ["Wanted page","Another wanted page"];. —Manyman (talk) 08:37, August 3, 2010 (UTC)

Jeff, they already have an AjaxRC code on Admin Tools Wiki's Common.js. I'll insert it here, but how will I know, once that it is installed on my site, that it is functioning properly?--  Chris  talk   blog  12:16, August 3, 2010 (UTC)

/* Enables AjaxRC (Advanced auto refreshing recent changes and watchlist) */

ajaxPages = new Array("Special:RecentChanges", "Special:Watchlist", "Special:Log");

function setCookie(c_name,value,expiredays) { var exdate=new Date exdate.setDate(exdate.getDate+expiredays) document.cookie=c_name+ "=" +escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString) }

function getCookie(c_name) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(c_name + "=") if (c_start!=-1) { c_start=c_start + c_name.length+1 c_end=document.cookie.indexOf(";",c_start) if (c_end==-1) c_end=document.cookie.length return unescape(document.cookie.substring(c_start,c_end)) } } return "" }

function getXmlHttpRequestObject { if (window.XMLHttpRequest) { return new XMLHttpRequest; //Not Internet Explorer } else if(window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); //Internet Explorer } else { //fail silently } } getRCDataRO = getXmlHttpRequestObject; var cr = new RegExp("\r", "gm"); var lf = new RegExp("\n", "gm"); var endText = new RegExp(' [\t\s]*?[\t\s]*? ', "mi"); var rcTimer; var rcRefresh = 60000; function preloadAJAXRC { if (skin == "monaco") { s = 1; } else { s = 0; } ajaxRCCookie = (getCookie("ajaxload-"+wgPageName)=="on") ? true:false; document.getElementsByTagName("h1")[0].innerHTML += ' AJAX: '; document.getElementById("ajaxRCtoggle").checked = ajaxRCCookie; if (getCookie("ajaxload-"+wgPageName)=="on") loadRCData; }

function toggleRC { if (document.getElementById("ajaxRCtoggle").checked == true) { setCookie("ajaxload-"+wgPageName, "on", 30); loadRCData; } else { setCookie("ajaxload-"+wgPageName, "off", 30); clearTimeout(rcTimer); } }

function loadRCData { if (getRCDataRO.readyState == 4 || getRCDataRO.readyState == 0) { if (location.href.indexOf("/wiki/")) { rcURL = "http://" + location.hostname + "/wiki/" + wgPageName + location.search; } else { rcURL = "http://" + location.hostname + "/" + wgPageName + location.search; } getRCDataRO.open("GET", rcURL, true); getRCDataRO.onreadystatechange = parseRCdata; getRCDataRO.send(null); } }

function parseRCdata { if (getRCDataRO.readyState == 4) { textFilter = new RegExp(' .*? [\t\s]*?[\t\s]*? ', "i"); rawRCdata = getRCDataRO.responseText.replace(cr, "").replace(lf, ""); filteredRCdata = textFilter.exec(rawRCdata); updatedText = filteredRCdata[0].replace(' ', "").replace(endText, ""); document.getElementById("bodyContent").innerHTML = updatedText; rcTimer = setTimeout("loadRCData;", rcRefresh); } }

for (x in ajaxPages) { if (wgPageName == ajaxPages[x]) addOnloadHook(preloadAJAXRC); } /* End of AjaxRC */
 * Eww, get rid of that one and replace it with what Manyman last said. -- 12:19, August 3, 2010 (UTC)

One is really long but one is really short, do they both do the same exact thing though. And how will I know if it is working properly on my Wiki?--  Chris  talk   blog  12:46, August 3, 2010 (UTC)
 * Yes they do the exact same thing. I should know, I wrote them both. You'll see an AJAX checkbox on top of the selected pages, check that and they will auto-refresh. -- 12:57, August 3, 2010 (UTC)

I didn't know that you wrote the small one too. Anyways, what do you mean by selected pages. I really don't know much about this.--  Chris  talk   blog  13:07, August 3, 2010 (UTC)

Wait, this wasn't resolved Jeff! Pcj, what do you mean by selected pages?--  Chris  talk   blog  16:57, August 3, 2010 (UTC)

Ok, I re-checked everything and figured it out.--  Chris  talk   blog  19:32, August 3, 2010 (UTC)

I'd like to do that as well, but I know absolutely nothing about JavaScript and I don't understand what to do with the code. (I feel like a total n00b now.) The   Slicer  23:55, August 3, 2010 (UTC)
 * Use:

importScriptPage('AjaxRC/code.js', 'dev'); ajaxPages = ["Wanted page","Another wanted page"]; —Manyman (talk) 07:34, August 4, 2010 (UTC)

What exactly am I supposed to do with it? I'm sorry if I sound like a stupid new guy, but like I said, I don't know the first thing about JavaScript. The  Slicer  14:10, August 4, 2010 (UTC)

You must add this code to your MediaWiki:Common.js page, if you want a few, specific, pages to load automatically. I just needed this because I run a social networking wiki called Communipedia. : ) --  Chris  talk   blog  14:21, August 4, 2010 (UTC)