Користувач:Base/newtemplates.js

Матеріал з Вікіпедії — вільної енциклопедії.
Перейти до навігації Перейти до пошуку

Увага: Після публікування слід очистити кеш браузера, щоб побачити зміни.

  • Firefox / Safari: тримайте Shift, коли натискаєте Оновити, або натисніть Ctrl-F5 чи Ctrl-Shift-R (⌘-R на Apple Mac)
  • Google Chrome: натисніть Ctrl-Shift-R (⌘-Shift-R на Apple Mac)
  • Internet Explorer / Edge: тримайте Ctrl, коли натискаєте Оновити, або натисніть Ctrl-F5
  • Opera: натисніть Ctrl-F5
function httpGet(theUrl){
    var xmlHttp = null;
 
    xmlHttp = new XMLHttpRequest();
    xmlHttp.open( "GET", theUrl, false );
    xmlHttp.send( null );
    return xmlHttp.responseXML;
    }
    function newTemplates(limit){
    newTemplatesR = httpGet("http://uk.wikipedia.org/w/api.php?action=query&list=recentchanges&format=xml&rcnamespace=10&rcprop=user%7Ctitle&rclimit="+limit+"&rctype=new");
    newTemplates=newTemplatesR.getElementsByTagName('rc');
    newTempBlock="<div class=\"portal\" id=\'p-coll-print_export\'>";
    newTempBlock+="<h5>Нові шаблони<\/h5>";
    newTempBlock+="<div class=\"body\">";
    newTempBlock+="<ul>";
       for(i=0;i<limit;i++){
        template="<li class=\"basestyle-newtemplates\"><a href=\"/wiki/"+newTemplates[i].getAttribute('title')+"\">"+newTemplates[i].getAttribute('title')+"<\/a><\/li>";
        newTempBlock+=template+"\n";
        }

    newTempBlock+="<\/ul>";
    newTempBlock+="<\/div>";
    newTempBlock+="<\/div>";
    
    leftCol=document.getElementById('mw-panel');
    leftCol.innerHTML=leftCol.innerHTML+newTempBlock;
    }
newTemplates(20);