Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/customer/www/pages.e-democracy.org/public_html/includes/WebStart.php on line 37
http://pages.e-democracy.org/index.php?title=User:Emufarmers/edem.js&feed=atom&action=history User:Emufarmers/edem.js - Revision history 2022-11-28T07:48:51Z Revision history for this page on the wiki MediaWiki 1.26.2
Deprecated: assert(): Calling assert() with a string argument is deprecated in /home/customer/www/pages.e-democracy.org/public_html/includes/diff/DairikiDiff.php on line 584
http://pages.e-democracy.org/index.php?title=User:Emufarmers/edem.js&diff=8896&oldid=prev Emufarmers at 15:50, 26 October 2012 2012-10-26T15:50:08Z <p></p> <a href="http://pages.e-democracy.org/index.php?title=User:Emufarmers/edem.js&amp;diff=8896&amp;oldid=8895">Show changes</a> Emufarmers http://pages.e-democracy.org/index.php?title=User:Emufarmers/edem.js&diff=8895&oldid=prev Emufarmers: Blanked the page 2012-10-26T15:46:53Z <p>Blanked the page</p> <a href="http://pages.e-democracy.org/index.php?title=User:Emufarmers/edem.js&amp;diff=8895&amp;oldid=8260">Show changes</a> Emufarmers http://pages.e-democracy.org/index.php?title=User:Emufarmers/edem.js&diff=8260&oldid=prev Emufarmers: Created page with "/* Ajax batch delete thingy, version [0.1.1b] Originally from: http://en.wikipedia.org/wiki/User:Splarka/ajaxbatchdelete.js Notes: * It is a bit verbose, after debugging perhap..." 2011-10-22T05:27:22Z <p>Created page with &quot;/* Ajax batch delete thingy, version [0.1.1b] Originally from: http://en.wikipedia.org/wiki/User:Splarka/ajaxbatchdelete.js Notes: * It is a bit verbose, after debugging perhap...&quot;</p> <p><b>New page</b></p><div>/* Ajax batch delete thingy, version [0.1.1b]<br /> Originally from: http://en.wikipedia.org/wiki/User:Splarka/ajaxbatchdelete.js<br /> <br /> Notes:<br /> * It is a bit verbose, after debugging perhaps some output should be removed.<br /> * It waits 1 second after every delete before starting the next.<br /> * Can be aborted by simply deleting the contents of the textarea, or leaving the page.<br /> * Stops when it hits a blank line.<br /> * Nonfatal errors (skip to next line):<br /> ** Bad character or malformed line<br /> ** Bad token<br /> ** Unexpected response<br /> * Pauses in execution can be added with a blank line.<br /> <br /> To do:<br /> * Cache the token if two the same?<br /> ** Please note the delete token is not guaranteed to be static, but currently it always is.<br /> */<br /> <br /> addOnloadHook(function() {<br /> addPortletLink('p-tb','/wiki/Special:BlankPage?blankspecial=ajaxbd','Batch Delete');<br /> });<br /> <br /> if(wgCanonicalSpecialPageName &amp;&amp; wgCanonicalSpecialPageName.toLowerCase() == 'blankpage' &amp;&amp; queryString('blankspecial') == 'ajaxbd') {<br /> document.title = 'Ajax Batch Deletion';<br /> addOnloadHook(abdForm);<br /> }<br /> <br /> function abdForm() {<br /> addPortletLink('p-tb','/wiki/Special:Log/delete?user=' + encodeURIComponent(wgUserName),'My delete log');<br /> <br /> //subvert this Special: page to our own needs.<br /> var con = document.getElementById('content') || document.getElementById('mw_content');<br /> var bcon = document.getElementById('bodyContent') || document.getElementById('mw_contentholder');<br /> var fh = getElementsByClassName(con,'h1','firstHeading')[0];<br /> while(fh.firstChild) fh.removeChild(fh.firstChild)<br /> fh.appendChild(document.createTextNode('Ajax Batch Deletion'));<br /> for(var i=0;i&lt;bcon.childNodes.length;i++) {<br /> bcur = bcon.childNodes[i];<br /> if(bcur.id != 'siteSub' &amp;&amp; bcur.id != 'contentSub' &amp;&amp; bcur.className != 'visualClear') {<br /> while(bcur.firstChild) bcur.removeChild(bcur.firstChild)<br /> if(bcur.nodeType == 3) bcur.nodeValue = '';<br /> }<br /> }<br /> <br /> //generate content<br /> var form = document.createElement('form');<br /> form.appendChild(document.createTextNode('List of pages to delete:'));<br /> form.appendChild(document.createElement('p'));<br /> form.setAttribute('action','javascript:void(0);');<br /> var txt = document.createElement('textarea');<br /> txt.style.height = '20em';<br /> txt.style.width = '50%';<br /> txt.setAttribute('id','abd-textarea');<br /> form.appendChild(txt);<br /> form.appendChild(document.createElement('p'));<br /> var lab1 = document.createElement('label');<br /> lab1.setAttribute('for','abd-reason')<br /> lab1.appendChild(document.createTextNode('Deletion reason: '));<br /> form.appendChild(lab1);<br /> var inp1 = document.createElement('input');<br /> inp1.style.width = '20em';<br /> inp1.setAttribute('type','text');<br /> inp1.setAttribute('id','abd-reason');<br /> form.appendChild(inp1);<br /> form.appendChild(document.createElement('p'));<br /> var sub1 = document.createElement('input');<br /> sub1.setAttribute('type','button');<br /> sub1.setAttribute('id','abd-startbutton');<br /> sub1.setAttribute('value','start');<br /> sub1.setAttribute('onclick','abdStart()');<br /> form.appendChild(sub1);<br /> bcon.appendChild(form);<br /> var pre = document.createElement('pre');<br /> pre.setAttribute('id','abd-output');<br /> bcon.appendChild(pre);<br /> }<br /> <br /> function abdStart() {<br /> document.getElementById('abd-startbutton').setAttribute('disabled','disabled');<br /> var out = document.getElementById('abd-output');<br /> var txt = document.getElementById('abd-textarea');<br /> var deletes = txt.value.split('\n');<br /> var page = deletes[0];<br /> if(page == '') {<br /> out.appendChild(document.createTextNode('* Done! Nothing left to do, or next line is blank.\n'));<br /> document.getElementById('abd-startbutton').removeAttribute('disabled');<br /> } else {<br /> var badchars = /(\#|\&lt;|\&gt;|\[|\]|\{|\}|\|)/;<br /> if(badchars.test(page)) {<br /> out.appendChild(document.createTextNode('! Illegal characters detected, skipping:' + page + '\n'));<br /> setTimeout('abdStart()',1000);<br /> } else {<br /> out.appendChild(document.createTextNode('&gt; Attempting to delete [[' + page + ']]\n'));<br /> abdGetToken(page);<br /> }<br /> }<br /> deletes = deletes.slice(1,deletes.length);<br /> txt.value = deletes.join('\n');<br /> }<br /> <br /> function abdGetToken(page) {<br /> var out = document.getElementById('abd-output');<br /> out.appendChild(document.createTextNode(' &gt; Fetching delete token for [[' + page + ']]\n'));<br /> var url = wgScriptPath + '/api.php?action=query&amp;prop=info&amp;indexpageids=1&amp;intoken=delete&amp;format=json&amp;titles=' + encodeURIComponent(page);<br /> var req = sajax_init_object();<br /> req.open('GET', url, true);<br /> req.onreadystatechange = function() {<br /> if(req.readyState == 4 &amp;&amp; req.status == 200) {<br /> eval(&quot;abdDelete(&quot; + req.responseText + &quot;,'&quot; + req.responseText.replace(/\'/g,&quot;`&quot;) + &quot;','&quot; + page + &quot;')&quot;);<br /> }<br /> }<br /> req.send(null);<br /> }<br /> <br /> function abdDelete(obj,txt,page) {<br /> var out = document.getElementById('abd-output');<br /> if(obj['error']) {<br /> out.appendChild(document.createTextNode(' ! Api error: ' + obj['error']['code'] + ' - ' + obj['error']['info'] + '\n'));<br /> return;<br /> }<br /> if(!obj['query'] || !obj['query']['pageids'] || !obj['query']['pages'][obj['query']['pageids'][0]] || !obj['query']['pages'][obj['query']['pageids'][0]]['deletetoken']) {<br /> out.appendChild(document.createTextNode(' ? Unexpected response: ' + txt + '\n'));<br /> return;<br /> }<br /> var token = obj['query']['pages'][obj['query']['pageids'][0]]['deletetoken'];<br /> out.appendChild(document.createTextNode(' &gt; Token found, attempting delete\n'));<br /> var reason = document.getElementById('abd-reason').value;<br /> <br /> var params = 'action=delete&amp;format=json&amp;token=' + encodeURIComponent(token) + '&amp;title=' + encodeURIComponent(page) + '&amp;reason=' + encodeURIComponent(reason);<br /> var url = wgScriptPath + '/api.php';<br /> <br /> var req = sajax_init_object();<br /> req.open('POST', url, true);<br /> req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');<br /> req.setRequestHeader('Content-length', params.length);<br /> req.setRequestHeader('Connection', 'close');<br /> req.onreadystatechange = function() {<br /> if(req.readyState == 4 &amp;&amp; req.status == 200) {<br /> eval(&quot;abdDeleteAftermath(&quot; + req.responseText + &quot;,'&quot; + req.responseText.replace(/\'/g,&quot;`&quot;) + &quot;')&quot;);<br /> }<br /> }<br /> req.send(params);<br /> }<br /> <br /> function abdDeleteAftermath(obj,txt) {<br /> var out = document.getElementById('abd-output');<br /> if(obj['error']) {<br /> out.appendChild(document.createTextNode(' ! Api error: ' + obj['error']['code'] + ' - ' + obj['error']['info'] + '\n'));<br /> } else if(obj['delete'] &amp;&amp; obj['delete']['title']) {<br /> out.appendChild(document.createTextNode(' &gt; Page [[' + obj['delete']['title'] + ']] deleted\n'));<br /> } else {<br /> out.appendChild(document.createTextNode(' ? Unexpected response: ' + txt + '\n'));<br /> return;<br /> }<br /> setTimeout('abdStart()',1000);<br /> }<br /> <br /> function queryString(p) {<br /> var re = RegExp('[&amp;?]' + p + '=([^&amp;]*)');<br /> var matches;<br /> if (matches = re.exec(document.location)) {<br /> try { <br /> return decodeURI(matches[1]);<br /> } catch (e) {<br /> }<br /> }<br /> return null;<br /> }</div> Emufarmers