MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */

function convertDate(dateString) { dc = dateString.split(" "); m = dc[2]; switch(m) { case "Jan": mm = "01"; break; case "Feb": mm = "02"; break; case "Mar": mm = "03"; break; case "Apr": mm = "04"; break; case "May": mm = "05"; break; case "Jun": mm = "06"; break; case "Jul": mm = "07"; break; case "Aug": mm = "08"; break; case "Sep": mm = "09"; break; case "Oct": mm = "10"; break; case "Nov": mm = "11"; break; case "Dec": mm = "12"; break; }   dd = dc[3] + "-" + mm + "-" + dc[1] return dd; }

function replaceLinks(text) { result=text.replace(/(https?:\/\/([-\w\.]+)+(:\d+)?(\/([\w\/_\.]*(\?\S+)?)?)?)/g,'$1'); return result; }

function convertors {

// getting SF activity feed

feed1 = document.getElementById("feedholder"); if (feed1) { if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest } else { xhttp=new ActiveXObject("Microsoft.XMLHTTP") } xhttp.open("GET","/export/rss2_keepsake.php?group_id=49159", false); xhttp.send(""); xmlDoc=xhttp.responseXML.getElementsByTagName("item"); str = " Latest activity  "; for(var i=0; i<5; i++){ // str += "" + xmlDoc[i].getElementsByTagName("pubDate")[0].childNodes[0].nodeValue + " : "; str += "" + convertDate(xmlDoc[i].getElementsByTagName("pubDate")[0].childNodes[0].nodeValue) + " : "; str += ""; str += xmlDoc[i].getElementsByTagName("title")[0].childNodes[0].nodeValue; str += ""; }       str += ""; feed1.innerHTML = str; }

// getting mantis feed

feed2 = document.getElementById("mantisholder"); if (feed2) { if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest } else { xhttp=new ActiveXObject("Microsoft.XMLHTTP") } xhttp.open("GET","/apps/mantisbt/free-cad/issues_rss.php?project_id=0", false); xhttp.send(""); xmlDoc=xhttp.responseXML.getElementsByTagName("item"); str = " Latest issues  "; for(var i=0; i<5; i++){ tag = xmlDoc[i].getElementsByTagName("title")[0].childNodes[0].nodeValue; str += "" + tag.substring(0,7) + " : "; str += "<a href=" + xmlDoc[i].getElementsByTagName("link")[0].childNodes[0].nodeValue + ">"; str += tag.substring(9,tag.length) + "</a></li>"; }       str += "</ul>"; feed2.innerHTML = str; }

// getting laconica feed

feed3 = document.getElementById("newsholder"); if (feed3) { if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest } else { xhttp=new ActiveXObject("Microsoft.XMLHTTP") } xhttp.open("GET","/apps/laconica/free-cad/search/notice/rss?q=freecad", false); xhttp.send(""); xmlDoc=xhttp.responseXML.getElementsByTagName("item"); //document.write(xmlDoc.toString); //document.write(xmlDoc.length); str = " Latest news <a href=/apps/laconica/free-cad/rss><img border=0 src=/userapps/mediawiki/yorikvanhavre/nfs/user/y/yo/yorikvanhavre/1/17/Rssicon.png></a> "; for(var i=0; i<5; i++){ tag = xmlDoc[i].getElementsByTagName("title")[0].childNodes[0].nodeValue; dat = xmlDoc[i].getElementsByTagName("dc:date")[0].childNodes[0].nodeValue; str += "" + dat.substring(0,10) + " : "; str += replaceLinks(tag) + "</li>"; }       str += "</ul>"; feed3.innerHTML = str; }

// getting API content

apidiv = document.getElementById("APIcontent"); if (apidiv) { if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest } else { xhttp=new ActiveXObject("Microsoft.XMLHTTP") } xhttp.open("GET","//free-cad.svn.sourceforge.net/viewvc/free-cad/trunk/src/Mod/Part/App/TopoShapePy.xml", false); //xhttp.open("GET","//sourceforge.net/apps/mantisbt/free-cad/issues_rss.php?project_id=0",false); xhttp.send(""); // xmlDoc=xhttp.responseXML.getElementsByTagName("Documentation"); apidiv.innerHTML = "test ok"; }

// getting facebook box

fbdiv = document.getElementById("fbholder"); if (fbdiv) { fbdiv.innerHTML = '<iframe src="http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Fpages%2FFreeCAD%2F153482088014175&amp;width=300&amp;connections=5&amp;stream=true&amp;header=false&amp;height=555" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:300px; height:470px;" allowTransparency="true"> '; }

// adding SF logo

footer = document.getElementById("f-poweredbyico"); if (footer) { ct = footer.innerHTML; ct += ' <a href="http://sourceforge.net/projects/free-cad"><img src="http://sflogo.sourceforge.net/sflogo.php?group_id=49159"'; ct += 'width="80" height="31" alt="FreeCAD Project on SourceForge.net." /></a>'; ct += ' <a href="http://crowdin.net/project/freecad"><img src="http://sourceforge.net/apps/mediawiki/free-cad/nfs/project/f/fr/free-cad/1/1a/Crowdin.jpg"'; ct += 'alt="FreeCAD Project on Crowdin." /></a>'; footer.innerHTML = ct; } }

addOnloadHook(convertors);