View source: File viewer
Views
Page
View source
We looking for new a maintainer for AndyZ's peerreviewer script, see
WT:Peer review
for details.
You can view and copy the source of this page:
<script type="text/javascript" src="/~dispenser/resources/tablefilter.js"></script> <script type="text/javascript">/*<![CDATA[*/ // TODOs // Add sort option try { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ xhr = new XMLHttpRequest(); } domain = "en.wikipedia.org"; function getFile(path, f) { //show throbber document.getElementById('puttablehere').innerHTML='<img style="display:block;margin:4em auto;text-align:center;" src="/~dispenser/resources/loadbar.gif" alt="Loading..."/>' if(path.indexOf(location.hostname)<0){ alert('AJAX requests only works in the same domain.'); } // update the hash // FIXME decenteralize location.hash = path.replace(/^http:\/+(toolserver\.org|tools\.wikimedia\.de)\/(~|%7E)/i, '').replace(/dispenser\/logs\/([\w\-.,]+)$/, 'log:$1').replace(/\//g, ':'); dm = path.match(/\b([a-z]{2,})\.?(wiki|wikibooks|wikinews|wikiquote|wikisource|wikiversity|wiktionary)\b/); if(dm) domain = dm[1]+"."+(dm[2]=="wiki"?"wikipedia":dm[2])+".org"; xhr.onreadystatechange = function(){ if(xhr.readyState == 4){ reqsize = xhr.getAllResponseHeaders().match(/^Content-Length: (\d+)$/m) lastMod = xhr.getAllResponseHeaders().match(/^Last-Modified: ([\w:, ]+)$/m) document.getElementById('metadata').innerHTML = 'Viewing: <a href="'+path+'">'+path.substring(path.lastIndexOf('/')+1)+'</a> (' + (lastMod?Math.floor((new Date()-new Date(lastMod[1]))/86400000)+' days '+Math.round((new Date()-new Date(lastMod[1]))/3600000%24*10)/10 +' hours old, ':'') + (reqsize?Math.floor(reqsize[1]/1024)+' KB)':')') // Warn if loading large files if(reqsize && reqsize[1]/1024 > 250) if(!confirm("The file is "+(Math.round(reqsize[1]/10485.76)/100.0)+" MB. Loading this file may cause your browser to hang or crash. Do you still wish to load it?")){ // .innerHTML = 'Load aborted' return } if(xhr.status == 200) f(xhr.responseText); else //alert('Bad response ('+xhr.status+') content was:\n' + xhr.responseText) document.getElementById('puttablehere').innerHTML='<div>Bad response ('+xhr.status+') content was:\n' + xhr.responseText+'</div>'; } } xhr.open('GET', path, true); xhr.send(null); } function handleFileString(s) { try{lines=s.match(/\n/g).length}catch(e){lines=0} // Convert CVS files to the easier to parse TSV if(s.match("<!DOCTYPE html")) { //HTML file document.getElementById('puttablehere').innerHTML = s } else if(s.match('\t')){ tsv2domtable(s) } else if(s.match(',')) { // Test if table data if(s.match(/,/g).length < lines / 10) { document.getElementById('puttablehere').innerHTML = "<pre>"+wikify(s)+"</pre>"; }else { // Convert into a tsv as best as we can s = s.replace(/,/g, '\t') s = s.replace(/"(.*?)"/g, function(v,w){return w.replace(/\t/g, ',')}) s = s.replace(/""/g, '"') tsv2domtable(s) } } else { document.getElementById('puttablehere').innerHTML = "Could not determine type<pre>"+wikify(s)+"</pre>"; } } function wikify(s) { s = s.replace(/</g, '<'); s = s.replace(/^---{2,} *$/mg, '<hr />'); s = s.replace(/(<!--.*?-->)/g, '<span class="comment" style="color:gray">$1</span>'); s = s.replace( /^# ?(.*)/mg, "<ol><li>$1</li></ol>").replace(/<\/ol>\n<ol>/g, ''); s = s.replace(/^\* ?(.*)/mg, "<ul><li>$1</li></ul>").replace(/<\/ul>\n<ul>/g, ''); s = s.replace(/([\w+]*:\/\/[^<>\s"]*)/g, '<a href="$1">$1</a>'); s = s.replace(/('''.*?''')/g, "<b>$1</b>"); s = s.replace(/(''.*?'')/g, "<i>$1</i>"); return s.replace(/\[\[([^[\]{|}<>"]+?)\]\]/g, '[[<a href="http://'+domain+'/wiki/$1" class="extiw">$1</a>]]'); } function tsv2domtable(s){ table = document.createElement('table') table.className="wikitable" var rows = s.split('\n') previous_page = ''; // state variable //TODO rows with len < 2 should be put into pre tag at the top of the page for(i=0; rows[i]!=null; i++){ cells=rows[i].split('\t') tr = table.insertRow(-1) for(j=0; (cell=cells[j])!=null; j++){ td=tr.insertCell(j) td.innerHTML=cell.replace(/^\s\s*/, '').replace(/</g, '<').replace(/\[\[([^[\]{|}<>"]+?)\]\]/g, '[[<a href="http://'+domain+'/wiki/$1" class="extiw">$1</a>]]') } m = rows[i].match(/\[\[[^[\]{|}<>\n]+/) if(m) if(previous_page == m[0]) //tr.style.backgroundColor="#aaa" tr.style.color="#666" else previous_page = m[0] if(j==1) // fill all columns td.colSpan=99//HACK } window.status = i + ' rows loaded' // Setup table filter with(document.getElementById('puttablehere')) replaceChild(table,firstChild) table.id='table'+Math.floor(Math.random()*1000) setFilterGrid(table.id, -1) } function load(s){ if(typeof s == typeof "string") location.hash=s if(location.hash){ m = location.hash.match(/#log[=:]([\w\-.,]+)/); document.getElementById('path').value="http://toolserver.org/~"+(m?"dispenser/logs/"+m[1]:location.hash.substring(1).replace(/:/g, '/')); getFile(document.getElementById('path').value, handleFileString); } } addOnloadHook(load) /*]]>*/</script> <fieldset> <legend>File</legend> <form action="javascript:" onsubmit="getFile(document.getElementById('path').value, handleFileString);"> The AJAX file viewer convert [[delimiter-separated values]] into a [[Filter (software)|filterable table]], allowing hiding of unwanted data. <label for="path">File path: </label><input type="text" id="path" name="path" size="70" value="" /><input type="submit" value="Load file" accesskey="o" /> <div style="font-size:x-small;">Examples: <a href="javascript:load('log:coord-commonswiki.log');">coord-commonswiki.log</a>, <a href="javascript:load('log:coord-dewiki.log');">coord-dewiki.log</a>, <a href="javascript:load('log:coord-enwiki.log');">coord-enwiki.log</a>, <a href="javascript:load('log:coord-frwiki.log');">coord-frwiki.log</a>, <a href="javascript:load('log:coord-nlwiki.log');">coord-nlwiki.log</a></div> </form> </fieldset> <div id="metadata"></div> <div id="puttablehere"><span></span></div>
Interaction
Main page
Recent changes
Tools
Altviewer
Checklinks
Dablinks
Geodata
Peer reviewer
Pywikipedia
Reflinks
Interaction
Preferences