Декъашхо:Sasan700/undocomment.js
Билгалдаккхар: Ӏалашйинчул тӀаьхьа хийцамаш га браузеран кэш цӀанйан йезаш хила мега.
- Firefox / Safari: Shift тӀетаӀийна йитина, гӀирсийн панелан тӀера тӀетаӀайе Карлайаккха йа Ctrl+F5 йа Ctrl+R (⌘+R Mac тӀехь)
- Google Chrome: тӀетаӀайе Ctrl+Shift+R (⌘+Shift+R Mac тӀехь)
- Internet Explorer / Edge: тӀетаӀийна йитина Ctrl, тӀетаӀайе Карлайаккха йа тӀетаӀайе Ctrl+F5
- Opera: тӀетаӀайе Ctrl+F5.
//Тlетуху баьццира цаоьшу оле нуьйда, биначу хийцамна могlан бухахь
var undoComment = new function (){
var oldrev, newrev
this.onLoad = function(){
//get undo revisions
oldrev = document.URL.match(/&undoafter=(\d+)/)[1]
newrev = document.URL.match(/&undo=(\d+)/)[1]
if (!oldrev || !newrev) return
//append new summary button
var buts = document.getElementById('userSummaryButtonsA')
if (!buts) return
a = document.createElement('a')
a.innerHTML = 'цаоьшу…'
a.href = 'javascript:undoComment.Go()'
buts.appendChild(a)
}
this.Go = function(){
apiRun(insertSummary, 'query&prop=revisions&rvlimit=10&rvprop=ids|user&titles='
+encodeURIComponent(mw.config.get('wgPageName')) + '&rvstartid=' + newrev)
}
function insertSummary(response){
data = response
try { eval('q='+response) } catch(e){return}
if (!q || !q.query || !(q.query.pages)) return alert('Кхетаме доцу жоп ду гlулкхдечун чура')
var i, authors = '', po=-1, pn=-1, hist = anyChild(q.query.pages).revisions
//find revisions
for (i=hist.length-1; i>=0; i--)
if (hist[i].revid == oldrev) po = i
for (i=po; i>=0; i--)
if (hist[i].revid == newrev) pn = i
if (po<0 || pn<0) return alert('Къанйелла башхо кара ца йина иттях нисйиначарна юккъехь')
//find all users
for (i=pn; i<po; i++)
if (authors.indexOf([hist[i].user]) == -1)
authors += ((authors=='')?'':', ') + [hist[i].user]
document.getElementById('wpSummary').value = 'Цаоьшу ' + (po-pn) + ' нисйинарш '
+ ((authors.indexOf(',') == -1)
? '['+'[User:'+authors+'|'+authors+']]'
: '(' + authors + ')' )
+ ', юхаяккха оцу башхон ' + oldrev + ' декъашхон ' + hist[po].user + ' : '
}
function apiRun(func, params){
var ajax = sajax_init_object()
ajax.onreadystatechange=function() {
if (ajax.readyState != 4) return
if (ajax.status == 200) {
func(ajax.responseText)
} else func(null)
}
ajax.open('GET', '/w/api.php?format=json&action='+params, true)
//ajax.setRequestHeader('Accept','text/*')
ajax.send(null)
}
function anyChild(obj) { for(var key in obj) return obj[key]; return null; }
}
if ((wgAction=='edit' || wgAction=='submit') && document.URL.indexOf('undo=')!=-1)
$(undoComment.onLoad)