Користувач:MaryankoD/monobook.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
importScript('User:Lupin/popups.js', 'en');
importScript('User:Ahonc/markadmains');
importScript('Користувач:AS/strings-uk.js');
importScript('User:Ilmari_Karonen/watchsince.js','en');
$(function () {

   // Check if we're on the watchlist
   if (!wgCanonicalSpecialPageName || wgCanonicalSpecialPageName != "Watchlist") return;
   if (!document.forms[0] || !document.forms[0].namespace) return;

   // Unwatch links go back to watchlist with "Removing requested items from watchlist..." message
   var query_prefix = "title="+encodeURIComponent(mw.config.get('wgPageName'))+"&action=submit&remove=1&id[]=";

   // ...or...
   // Unwatch links go to "Removed from watchlist" page
   //var query_prefix = "action=unwatch&title=";

   // get list of all links in content:
   var links = document.getElementById('content').getElementsByTagName('a');

   // make a static copy of the nodelist and lose the original for speed
   // while we're at it, prune the uninteresting links from the list
   var linksCopy = new Array ();
   for (var i = 0; i < links.length; i++) {
       if (/[?&]action=history([&#]|$)/.test(links[i].href)) linksCopy.push(links[i]);
   }
   links = linksCopy;

   for (var i = 0; i < links.length; i++) {
       // create unwatch link and append it after history link
       var unwatch = document.createElement('a');
       unwatch.href = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/index.php?" + query_prefix + encodeURIComponent(links[i].title);
       unwatch.title = "Скасувати спостереження за "+links[i].title;
       unwatch.appendChild(document.createTextNode("скас."));
       links[i].parentNode.insertBefore(unwatch, links[i].nextSibling);

       // insert a delimiter between the two links
       var delim = links[i].previousSibling;
       delimText = (delim.nodeType == 3 ? delim.nodeValue : ""); // kluge to handle case where "diff" is unlinked
       delim = document.createTextNode(delimText.replace(/^.*diff/, ""));
       links[i].parentNode.insertBefore(delim, unwatch);
   }
});

var basecount=195133;
var basetime=new Date(Date.UTC(2007, 7, 14, 12, 31, 0, 0))
var curcount=0;
var updrest=10;
 
function LiveCountReq() {
   req.onreadystatechange = processCount;
   req.open("GET", "http://uk.wikipedia.org/wiki/Special:Statistics?action=raw&randomseed="+Math.floor(Math.random()*10000000), true);
   req.send(null);
 }
 function processCount() {
   if (req.readyState == 4) {
     if (req.status == 200) {
       curcount=req.responseText.substring(req.responseText.indexOf('good=',1)+5, 
                                             req.responseText.indexOf(';views=',1)); 
       var curtime=new Date;
       var progn=(250000-basecount)*
                 (curtime.valueOf()-basetime.valueOf())/
                 (curcount-basecount)+basetime.valueOf();
       var progd=new Date(progn);
       document.getElementById('articlecount').innerHTML=curcount;
       var secs=Math.floor((progd-curtime)/1000)
       var days=Math.floor(secs/24/60/60);
       var hours=Math.floor((secs-days*24*60*60)/60/60);
       var mins=Math.floor((secs-days*24*60*60-hours*60*60)/60);
       var lsecs=Math.floor(secs-days*24*60*60-hours*60*60-mins*60);
       document.getElementById('articlecountdown').innerHTML=Math.floor(days/10)+''+days%10+'d '+Math.floor(hours/10)+hours%10+':'+Math.floor(mins/10)+mins%10+':'+Math.floor(lsecs/10)+lsecs%10;
     } else {
       document.getElementById('articlecount').innerHTML='??????';
       document.getElementById('articlecountdown').innerHTML='??????';
     }
     updrest-=1;
     if (updrest>0) {
       setTimeout('LiveCountReq();',60000); 
     } else {
       document.getElementById('articlecount').innerHTML='??????';
       document.getElementById('articlecountdown').innerHTML='??????';
     }
   }
 }
 function updateLastMouse(e) {
   if (updrest<1) {
     updrest=10;
     setTimeout('LiveCountReq();',1000); 
   } else {
     updrest=10;
   }
 }
 function addLiveCount()
 {
    req = null;
    if (window.XMLHttpRequest) {
        try {
            req = new XMLHttpRequest();
        } catch (e){}
    } else if (window.ActiveXObject) {
        try {
            req = new ActiveXObject('Msxml2.XMLHTTP');
        } catch (e){
            try {
                req = new ActiveXObject('Microsoft.XMLHTTP');
            } catch (e){}
        }
    }
    if (req) {
      document.getElementById('p-logo').innerHTML='<a style="background-image: url(http://upload.wikimedia.org/wikipedia/uk/b/bc/Wiki.png);" href="/wiki/Головна_стаття" title="Перейти до Головної сторінки [z]" accesskey="z"></a><div id="articlecount" style="display:block;position:absolute;left:5px;top:100px;align:center; color:#222222; font-size: 8pt;opacity:0.6;background:#FFFFFF;padding:0em 0.25em;">??????</div><div id="articlecountdown" style="display:block;position:absolute;left:60px;top:100px;align:center; color:#773333; font-size: 8pt;opacity:0.0;background:#FFFFFF;padding:0em 0.25em;">??????</div>'
 
 
   if (window.addEventListener) 
     window.addEventListener("mousemove", updateLastMouse, false);
   else 
     if (window.attachEvent) 
       window.attachEvent("mousemove", updateLastMouse);
   LiveCountReq(); 
    }
 }
 addOnloadHook(addLiveCount);
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<title>Patrolling new images!</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<!-- <meta name="robots" content="noindex,nofollow"> -->
 
    <style type="text/css" media="screen,projection">/*<![CDATA[*/
        @import "http://en.wikipedia.org/skins-1.5/common/shared.css?80";
        @import "http://en.wikipedia.org/skins-1.5/monobook/main.css?80";
        @import "../misza.css";
    /*]]>*/</style>
	</head>
		<body class="mediawiki">
 
		<div id="globalWrapper">
		<div id="column-content">
		<div id="content">
 
		<h1>Patrolling the new images!</h1><br/>
			<p>This is a tool written by <a href="http://it.wikipedia.org/wiki/Utente:Filnik" title="Filnik">Filnik</a> to patrol the latest images that are uploaded<br/>
			on the different wikimedia projects. I'm still working on this tool, so don' judge until I've finished it :-)<br/>
			If you want to go to the image's page, just click on the image.
			<br/><br/>
			Here you have to defain in what project you want to use that script (example: "commons.wikimedia.org").
			<br /><br />
			<b><a href="http://www.botwiki.sno.cc/wiki/Php:NewImages.php" title="Source">Source</a></b>
			<br />
			</p>
		<br />
		<?PHP
		echo "<form method=\"get\" action=\"{$_SERVER['PHP_SELF']}\"  /><input type=\"text\" name=\"domain\" value=\"it.wikipedia.org\" />";
		?>
 
		<input type="submit" value="Enter" />
		<br/>
 
<?PHP
 
function resize($width, $height)
{
	$number = 400;
	if ($width > $height)
	{	
		if ($width > $number){$width = $number;}
		$imageInfo = '" width="' . $width . '"';
	}else{
		if ($height > $number){$height = $number;}
		$imageInfo = '" height="' . $height . '"';
		}
	return $imageInfo;
}
 
function getPage($domain, $url, $wk = 'wiki') 
{
	$ch = curl_init("http://$domain/$wk/$url");
	# manda l'useragent
	curl_setopt ($ch, CURLOPT_USERAGENT, "'Filnik's NewImages.php");#"Mozilla/5.0 (X11; U; Linux i686; it; rv:1.8.1.3) Gecko/20060601 Firefox/2.0.0.4 (Ubuntu-edgy)");
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, True); // Follow the redirects
	curl_setopt($ch, CURLOPT_MAXREDIRS, 5); // Follow no more than 5 redirects
	# legge il risultato
	$risultato = curl_exec($ch);
	curl_close($ch);
	# ritorna il risultato
	return $risultato;
}
 
if (isset($_REQUEST['domain']))
{
 
    $domain = $_REQUEST['domain'];
    if ($domain == ''){$domain = 'commons.wikimedia.org';}
    #$pageSpecialLog = 'Speciale:Registri/upload';
    $pageSpecialLog = 'Special:Log/upload';
 
    if (isset($_REQUEST['offset']) or isset($_REQUEST['limit'])){
            $limit = $_REQUEST['limit'];
            $offset = $_REQUEST['offset'];
            $pageSpecialLog = "index.php?title=Special:Log&limit=$limit&offset=$offset&type=upload&user=&page=&pattern=";
            $logText = getPage($domain, $pageSpecialLog, 'w');
    }else{
            $logText = getPage($domain, $pageSpecialLog);
            }
 
    $offsetmin = $offset - 50;
    $offsetmax = $offset + 50;
    if ($offset >= 50){
    echo '<p>See (<a href="http://tools.wikimedia.de/~filnik/newimages.php?domain=' . $domain . '&limit=' . $limit . '&offset=' . $offsetmin . '" class="mw-prevlink">previous 50</a>) ';
    }else{
    echo '<p>See (previous 50)';
    }
    echo ' (<a href="http://tools.wikimedia.de/~filnik/newimages.php?domain=' . $domain . '&limit=' . $limit . '&offset=' . $offsetmax . '" class="mw-prevlink">next 50</a>) </p>
    <br />';
 
    echo '		<center><h2>Image log</h2></center>
                    <br />';
 
    // title="Immagine:Brumano-Stemma.png">Immagine:Brumano-Stemma.png</a>" ‎ <span class="comment">
    $regex = '/title=\".*?\.(?:\w\w\w|[Jj][Pp][Ee][Gg])\">(.*?)<.a>\"\s*?/';#span class=\"comment\">/';
    preg_match_all($regex, $logText, $results);
    //print_r($results);
 
    $imagesList = array_unique($results[1]);
 
    foreach($imagesList as $image)
    {
            $urlimage = str_replace(' ', '_', $image);
            $imageText = getPage($domain, $urlimage);
            $regexImage = '/<img alt ?= ?\"' . $image . '" ?src ?= ?"(.*?)" width="(.*?)" height="(.*?)"/';
            preg_match_all($regexImage, $imageText, $foulder);
            $ImageDirectLink = $foulder[1][0];
            $width = $foulder[2][0];
            $height = $foulder[3][0];
            $imageInfo = resize($width, $height);
 
            //tipo MIME: image/jpeg)
            //<!--\n/Pre-expand include size:
 
            $regexDescription = '/(?:MIME|file size):? ?.*?\)(?:<.div>)?(.*?)(?:<!-- ?\nPre-expand include size:|<h2 id=)/s';
            preg_match_all($regexDescription, $imageText, $DescriptionArray);
            #print_r($DescriptionArray[1][0]);
 
            $descriptionImage = str_replace('<a href="/w', '<a href="http://' . $domain . '/w', $DescriptionArray[1][0]);
            $descriptionImage = preg_replace('/id=".*?"/', '', $descriptionImage);
 
            $regexHistory = '/<table class="filehistory">(.*?)<.table>/s';
            preg_match_all($regexHistory, $imageText, $historyArray);
            $history = str_replace('<a href="/w', '<a href="http://' . $domain . '/w', $historyArray[1][0]);
 
            //Prevent the load of deleted images...
 
            if ($ImageDirectLink != ''){
            echo '<table class="prettytable" border="1" cellpadding="3" cellspacing="0" style="margin:0 .5em .5em 0; margin-top:.5em; margin-bottom:.5em; border:1px solid #CCC; border-collapse:collapse; font-family: Arial, Frutiger 45 Light, Helvetica, Arial Unicode MS, Lucida Sans Unicode, Lucida Grande, TITUS Cyberit Basic, Code2000, MV Boli, @MS Mincho;">
    <tr>
    <th>' . $image . '</th>
    <th colspan="3">Description</th>
    </tr>
    <tr>
    <td><i><br />';
            echo '<a href="http://' . $domain . '/wiki/' . $urlimage . '"><img alt="' . $image . '" src="' . $ImageDirectLink . $imageInfo . ' border="0" /></a>';
            echo '
    </i></td>
    <td style="font-size: 90%">' . $descriptionImage . '</td>
    </tr>
    <tr><td colspan="2" style="padding: 0px">
    <table class="filehistory" style="margin: 0px">' . $history . '</table>
    </td></tr>
    </table>
    <br/><br/>';	
 
            }
    }
 
    if ($offset >= 50){
    	echo '<p>See (<a href="http://tools.wikimedia.de/~filnik/newimages.php?domain=' . $domain . '&limit=' . $limit . '&offset=' . $offsetmin . '" class="mw-prevlink">previous 50</a>) ';
    }else{
    	echo '<p>See (previous 50)';
    }
    echo ' (<a href="http://tools.wikimedia.de/~filnik/newimages.php?domain=' . $domain . '&limit=' . $limit . '&offset=' . $offsetmax . '" class="mw-prevlink">next 50</a>) </p>
    <br />';
}
?>
 
</div><!--content-->
</div><!--column-content-->
<div id="column-one">
<div id="p-logo" class="portlet">
<a title="Hosted by the Wikimedia Toolserver" href="/" style="background-image: url(toolserv.png);"></a>
</div><!--p-logo-->
 
<div id="p-navigation" class="portlet">
<h5>Navigation</h5>
<div class="pBody">
<ul>
  <li><a href="index.php">Main</a></li>
</ul>
</div>
</div><!--p-navigation-->
 
</div><!--column-one-->
<div class="visualClear" />
<div id="footer">
 
<a href="http://tools.wikimedia.de/"><img
    src="http://tools.wikimedia.de/wikimedia-toolserver-button.png" 
    alt="Hosted on the Toolserver" /></a>
 
<a href="http://validator.w3.org/check?uri=referer"><img
    src="http://www.w3.org/Icons/valid-xhtml10-blue"
    alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>
 
</div><!--footer-->
</div><!--globalWrapper-->	
</body>
 
</html>