User:AlexDj94/Wikipedia More Alive.js

/* Copyright (C) 2011 Alessio Dionisi 

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to

Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor Boston, MA  02110-1301, USA.

function RealTimeWiki { //alert("debug: caricamento plugin..."); CheckLastRevision; }

function CheckLastRevision { if (window.XMLHttpRequest) // IE7+, Firefox, Chrome, Opera, Safari {     //alert("debug: ie7+ firefox chrome opera safari"); xmlhttp = new XMLHttpRequest; }  else // IE6, IE5 {     //alert("debug: ie6 ie5"); xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }  //alert("debug: reading xml..."); try { xmlhttp.open("GET", "http://it.wikipedia.org/w/api.php?action=query&prop=revisions&titles=Main_Page&format=xml", false); //xmlhttp.setRequestHeader("User-Agent", "WikipediaMoreAlive/1.0"); xmlhttp.send(null); }  catch(e) { alert("== Javascript Error ==\n" + e.toString); }  xmlDoc = xmlhttp.responseXML;

//alert("debug: get data..."); alert(xmlDoc.getElementsByTagName("page")[0].attributes.getNamedItem("title").nodeValue); }

$(document).ready(RealTimeWiki); //jQuery(RealTimeWiki);