User:Kb03/rtrc test.js

mw.loader.implement("ext.gadget.rtrc@0skr2l9",function($,jQuery,require,module){Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(r,e){if(null==this)throw new TypeError('"this" is null or not defined');var t=Object(this),n=t.length>>>0;if(0===n)return!1;var i,o,a=0|e,u=Math.max(a>=0?a:n-Math.abs(a),0);for(u<n;){if((i=t[u])===(o=r)||"number"==typeof i&&"number"==typeof o&&isNaN(i)&&isNaN(o))return!0;u++}return!1}});(function{'use strict';var appVersion='v1.3.6-pre.6',conf=mw.config.get(['skin','wgAction','wgCanonicalSpecialPageName','wgPageName','wgTitle','wgUserLanguage','wgDBname','wgScriptPath']),apiUrl=conf.wgScriptPath+'/api.php',cvnApiUrl='https://cvn.wmflabs.org/api.php',oresApiUrl='https://ores.wikimedia.org/scores/'+conf.wgDBname+'/',oresModel=!1,intuitionLoadUrl='https://meta.wikimedia.org/w/index.php?title=User:Krinkle/Scripts/Intuition.js&action=raw&ctype=text/javascript',docUrl= 'https://meta.wikimedia.org/wiki/User:Krinkle/Tools/Real-Time_Recent_Changes?uselang='+conf.wgUserLanguage,ajaxLoaderUrl='https://upload.wikimedia.org/wikipedia/commons/d/de/Ajax-loader.gif',annotationsCache={patrolled:Object.create(null),cvn:Object.create(null),ores:Object.create(null)},annotationsCacheSize=0,userHasPatrolRight=!1,rcTags=[],wikiTimeOffset,updateFeedTimeout,rcDayHeadPrev,skippedRCIDs=[],monthNames,prevFeedHtml,updateReq,defOpt={rc:{start:undefined,end:undefined,dir:'older',namespace:undefined,user:undefined,tag:undefined,hideliu:!1,hidebots:!0,unpatrolled:!1,limit:25,typeEdit:!0,typeNew:!0},app:{refresh:5,cvnDB:!1,ores:!1,massPatrol:!1,autoDiff:!1}},aliasOpt={showAnonOnly:'hideliu',showUnpatrolledOnly:'unpatrolled'},opt=makeOpt,timeUtil,message,msg,rAF=window.requestAnimationFrame||setTimeout,currentDiff,currentDiffRcid,$wrapper,$body,$feed,$RCOptionsSubmit;function makeOpt{return $.extend(true,{},defOpt);}function pad(num){return(num<10? '0':)+num;}timeUtil={newDateFromISO:function(s){return new Date(Date.parse(s));},applyUserOffset:function(d){var parts,offset=mw.user.options.get('timecorrection');if(offset){parts=offset.split('|');if(parts[0]==='System'){offset=wikiTimeOffset;}else{offset=Number(parts[1]);}}else{offset=wikiTimeOffset;}d.setTime(d.getTime+(offset*60*1000));return d;},getClocktimeFromApi:function(s){var d=timeUtil.applyUserOffset(timeUtil.newDateFromISO(s));return pad(d.getUTCHours)+':'+pad(d.getUTCMinutes);}};function buildRcDayHead(date){var current=date.getDate;if(current===rcDayHeadPrev){return;}rcDayHeadPrev=current;return' '+date.getDate+' '+monthNames[date.getMonth]+' ';}function buildRcItem(rc){var diffsize,isUnpatrolled,typeSymbol,itemClass,diffLink,el,item;diffsize=rc.newlen-rc.oldlen;isUnpatrolled=rc.unpatrolled!==undefined;typeSymbol=' ';itemClass=[];if(rc.type==='new'){typeSymbol+=' '+mw. message('newpageletter').escaped+' ';}if((rc.type==='edit'||rc.type==='new')&&userHasPatrolRight&&isUnpatrolled){typeSymbol+=' ! ';}if(rc.oldlen>0&&rc.newlen===0){itemClass.push('mw-rtrc-item-alert');}item=buildRcDayHead(timeUtil.newDateFromISO(rc.timestamp));item+='';if(rc.type==='edit'){diffLink=''+mw.message('diff').escaped+'';}else if(rc.type==='new'){diffLink=''+message('new-short').escaped+'';}else{diffLink=mw.message('diff').escaped;}item+=' '+'('+diffLink+') '+typeSymbol+' '+timeUtil.getClocktimeFromApi(rc.timestamp)+' '+rc.title+''+' '+ ' &middot; '+''+mw.message('talkpagelinktext').escaped+''+' &middot; '+''+mw.message('contribslink').escaped+''+' &middot; '+''+rc.user+''+' '+' '+rc.parsedcomment+'  ';if(diffsize>0){el=diffsize>399?'strong':'span';item+=' <'+el+' class="mw-plusminus mw-plusminus-pos">(+'+diffsize.toLocaleString+') ';}else if(diffsize===0){item+='  (0)  ';}else{el=diffsize<-399?'strong':'span';item+=' <'+el+ ' class="mw-plusminus mw-plusminus-neg">('+diffsize.toLocaleString+') ';}item+=' ';return item;}function normaliseSettings(newOpt,mode){var mod=!1;if(newOpt.app.massPatrol&&!newOpt.rc.user){newOpt.app.massPatrol=!1;mod=!0;if(mode!=='quiet'){alert(msg('masspatrol-requires-userfilter'));}}if(newOpt.app.massPatrol&&!newOpt.app.autoDiff){newOpt.app.autoDiff=!0;mod=!0;}if(newOpt.app.massPatrol&&!newOpt.rc.unpatrolled){newOpt.rc.unpatrolled=!0;mod=!0;}return!mod;}function fillSettingsForm(newOpt){var $settings=$($wrapper.find('.mw-rtrc-settings')[0].elements).filter(':input');if(newOpt.rc){$.each(newOpt.rc,function(key,value){var $setting=$settings.filter(function{return this.name===key;}),setting=$setting[0];if(!setting){return;}switch(key){case'limit':setting.value=value;break;case'namespace':if(value===undefined){$setting.find('option').eq(0).prop('selected',true);}else{$setting.val(value);}break;case'user':case'start':case'end':case'tag':setting. value=value||'';break;case'hideliu':case'hidebots':case'unpatrolled':case'typeEdit':case'typeNew':setting.checked=value;break;case'dir':if(setting.value===value){setting.checked=!0;}break;}});}if(newOpt.app){$.each(newOpt.app,function(key,value){var $setting=$settings.filter(function{return this.name===key;}),setting=$setting[0];if(!setting){setting=document.getElementById('rc-options-'+key);$setting=$(setting);}if(!setting){return;}switch(key){case'cvnDB':case'ores':case'massPatrol':case'autoDiff':setting.checked=value;break;case'refresh':setting.value=value;break;}});}}function readSettingsForm{var $settings=$($wrapper.find('.mw-rtrc-settings')[0].elements).filter(':input');opt=makeOpt;$settings.each(function(i,el){var name=el.name;switch(name){case'limit':opt.rc[name]=Number(el.value);break;case'namespace':opt.rc[name]=el.value.length?Number(el.value):undefined;break;case'user':case'start':case'end':case'tag':opt.rc[name]=el.value||undefined;break;case'hideliu':case 'hidebots':case'unpatrolled':case'typeEdit':case'typeNew':opt.rc[name]=el.checked;break;case'dir':if(el.checked){opt.rc[name]=el.value;}break;case'cvnDB':case'ores':case'massPatrol':case'autoDiff':opt.app[name]=el.checked;break;case'refresh':opt.app[name]=Number(el.value);break;}});if(!normaliseSettings(opt)){fillSettingsForm(opt);}}function getPermalink{var uri=new mw.Uri(mw.util.getUrl(conf.wgPageName)),reducedOpt={};$.each(opt.rc,function(key,value){if(defOpt.rc[key]!==value){if(!reducedOpt.rc){reducedOpt.rc={};}reducedOpt.rc[key]=value;}});$.each(opt.app,function(key,value){if(key!=='massPatrol'&&defOpt.app[key]!==value){if(!reducedOpt.app){reducedOpt.app={};}reducedOpt.app[key]=value;}});reducedOpt=JSON.stringify(reducedOpt);uri.extend({opt:reducedOpt==='{}'?'':reducedOpt});return uri.toString;}function updateFeedNow{$('#rc-options-pause').prop('checked',false);if(updateReq){updateReq.abort;}clearTimeout(updateFeedTimeout);return updateFeed;}function scrollIntoView( $element){$element[0].scrollIntoView({block:'start',behavior:'smooth'});}function scrollIntoViewIfNeeded($element){if($element[0].scrollIntoViewIfNeeded){$element[0].scrollIntoViewIfNeeded({block:'start',behavior:'smooth'});}else{$element[0].scrollIntoView({block:'start',behavior:'smooth'});}}function readPermalink{var group,oldKey,newKey,newOpt,url=new mw.Uri;if(url.query.opt){try{newOpt=JSON.parse(url.query.opt);}catch(e){}}if(newOpt){for(group in newOpt){for(oldKey in newOpt[group]){newKey=aliasOpt[oldKey];if(newKey&&!Object.hasOwnProperty.call(newOpt[group],newKey)){newOpt[group][newKey]=newOpt[group][oldKey];delete newOpt[group][oldKey];}}}if(newOpt.app){delete newOpt.app.massPatrol;}}newOpt=$.extend(true,makeOpt,newOpt);normaliseSettings(newOpt,'quiet');fillSettingsForm(newOpt);opt=newOpt;}function getApiRcParams(rc){var params,rcprop=['flags','timestamp','user','title','parsedcomment','sizes','ids'],rcshow=[],rctype=[];if(userHasPatrolRight){rcprop.push('patrolled');}if(rc .hideliu){rcshow.push('anon');}if(rc.hidebots){rcshow.push('!bot');}if(rc.unpatrolled){rcshow.push('!patrolled');}if(rc.typeEdit){rctype.push('edit');}if(rc.typeNew){rctype.push('new');}if(!rctype.length){rctype=['edit','new'];}params={rcdir:rc.dir,rclimit:rc.limit,rcshow:rcshow.join('|'),rcprop:rcprop.join('|'),rctype:rctype.join('|')};if(rc.dir==='older'){if(rc.end!==undefined){params.rcstart=rc.end;}if(rc.start!==undefined){params.rcend=rc.start;}}else if(rc.dir==='newer'){if(rc.start!==undefined){params.rcstart=rc.start;}if(rc.end!==undefined){params.rcend=rc.end;}}if(rc.namespace!==undefined){params.rcnamespace=rc.namespace;}if(rc.user!==undefined){params.rcuser=rc.user;}if(rc.tag!==undefined){params.rctag=rc.tag;}return params;}function applyRtrcAnnotations($feedContent){$feedContent.filter('.mw-rtrc-item').each(function{var $el=$(this),rcid=Number($el.data('rcid'));if(skippedRCIDs.includes(rcid)){$el.addClass('mw-rtrc-item-skipped');}else if(rcid in annotationsCache.patrolled) {$el.addClass('mw-rtrc-item-patrolled');}else if(rcid===currentDiffRcid){$el.addClass('mw-rtrc-item-current');}});}function applyOresAnnotations($feedContent){var dAnnotations,revids,fetchRevids;if(!oresModel){return $.Deferred.resolve;}revids=$.map($feedContent.filter('.mw-rtrc-item'),function(node){return $(node).attr('data-diff');});if(!revids.length){return $.Deferred.resolve;}fetchRevids=revids.filter(function(revid){return!(revid in annotationsCache.ores);});if(!fetchRevids.length){dAnnotations=$.Deferred.resolve(annotationsCache.ores);}else{dAnnotations=$.ajax({url:oresApiUrl,data:{models:oresModel,revids:fetchRevids.join('|')},timeout:10000,dataType:$.support.cors?'json':'jsonp',cache:!0}).then(function(resp){var len;if(resp){len=Object.keys?Object.keys(resp).length:fetchRevids.length;annotationsCacheUp(len);$.each(resp,function(revid,item){if(!item||item.error||!item[oresModel]||item[oresModel].error){return;}annotationsCache.ores[revid]=item[oresModel].probability ['true'];});}return annotationsCache.ores;});}return dAnnotations.then(function(annotations){revids.forEach(function(revid){var tooltip,score=annotations[revid];if(!score||score<=0.45){return;}tooltip=msg('ores-damaging-probability',(100*score).toFixed(0)+'%');$feedContent.filter('.mw-rtrc-item[data-diff="'+Number(revid)+'"]').addClass('mw-rtrc-item-alert mw-rtrc-item-alert-rev').find('.mw-rtrc-meta').prepend($(' ').addClass('mw-rtrc-revscore').attr('title',tooltip));});});}function applyCvnAnnotations($feedContent){var dAnnotations,users=[];$feedContent.filter('.mw-rtrc-item').each(function{var user=$(this).attr('user');if(user&&users.includes(user)&&!(user in annotationsCache.cvn)){users.push(user);}});if(!users.length){dAnnotations=$.Deferred.resolve(annotationsCache.cvn);}else{dAnnotations=$.ajax({url:cvnApiUrl,data:{users:users.join('|')},timeout:2000,dataType:$.support.cors?'json':'jsonp',cache:!0}).then(function(resp){if(resp.users){$.each(resp.users,function(name, user){annotationsCacheUp;annotationsCache.cvn[name]=user;});}return annotationsCache.cvn;});}return dAnnotations.then(function(annotations){$.each(annotations,function(name,user){var tooltip;if(user.type==='blacklist'){tooltip='';if(user.comment){tooltip+=msg('cvn-reason')+': '+user.comment+'. ';}else{tooltip+=msg('cvn-reason')+': '+msg('cvn-reason-empty');}if(user.adder){tooltip+=msg('cvn-adder')+': '+user.adder;}else{tooltip+=msg('cvn-adder')+': '+msg('cvn-adder-empty');}$feedContent.filter('.mw-rtrc-item').filter(function{return $(this).attr('user')===name;}).addClass('mw-rtrc-item-alert mw-rtrc-item-alert-user').find('.mw-userlink').attr('title',tooltip);}});});}function pushFeedContent(update){$body.removeClass('placeholder');$feed.find('.mw-rtrc-feed-update').html(message('lastupdate-rc',new Date.toLocaleString).escaped+' | '+message('permalink').escaped+'</a>');if(update.rawHtml!==prevFeedHtml){prevFeedHtml=update.rawHtml; applyRtrcAnnotations(update.$feedContent);$feed.find('.mw-rtrc-feed-content').empty.append(update.$feedContent);}}function updateFeed{if(updateReq){updateReq.abort;}$('#krRTRC_loader').show;updateReq=$.ajax({url:apiUrl,dataType:'json',data:$.extend(getApiRcParams(opt.rc),{format:'json',action:'query',list:'recentchanges'})});return updateReq.always(function{updateReq=null;}).then(function onRcSuccess(data){var recentchanges,$feedContent,client,feedContentHTML='';if(data.error){if(data.error.code==='rcpermissiondenied'){feedContentHTML+=' Downloading recent changes failed Please untick the "Unpatrolled only"-checkbox or request the Patroller-right.</a>';}else{client=$.client.profile;feedContentHTML+=' Downloading recent changes failed '+' Please check the settings above and try again. If you believe this is a bug, please '+'<a href="https://github.com/Krinkle/mw-gadget-rtrc/issues/new?body='+encodeURIComponent('\n\n\n'+ '\npackage: mw-gadget-rtrc '+appVersion+mw.format('\nbrowser: $1 $2 ($3)',client.name,client.version,client.platform))+'" target="_blank">let me know</a> .';}}else{recentchanges=data.query.recentchanges;if(recentchanges.length){$.each(recentchanges,function(i,rc){feedContentHTML+=buildRcItem(rc);});}else{feedContentHTML+=' '+message('nomatches').escaped+' ';}rcDayHeadPrev=undefined;}$feedContent=$($.parseHTML(feedContentHTML));return $.when(opt.app.cvnDB&&applyCvnAnnotations($feedContent),oresModel&&opt.app.ores&&applyOresAnnotations($feedContent)).then(null,function{return $.Deferred.resolve;}).then(function{return{$feedContent:$feedContent,rawHtml:feedContentHTML};});},function onRcError(jqXhr,textStatus){var feedContentHTML;if(textStatus==='abort'){return $.Deferred.reject;}feedContentHTML=' Downloading recent changes failed ';return{$feedContent:$(feedContentHTML),rawHtml:feedContentHTML};}).then(function(obj){pushFeedContent(obj );}).then(function{$RCOptionsSubmit.prop('disabled',false).css('opacity','1.0');updateFeedTimeout=setTimeout(updateFeed,opt.app.refresh*1000);$('#krRTRC_loader').hide;});}function nextDiff{var $lis=$feed.find('.mw-rtrc-item:not(.mw-rtrc-item-current, .mw-rtrc-item-patrolled, .mw-rtrc-item-skipped)');$lis.eq(0).find('a.rcitemlink').click;}function wakeupMassPatrol(settingVal){if(settingVal===true){if(!currentDiff){nextDiff;}else{$('.patrollink a').click;}}}function buildInterface{var namespaceOptionsHtml,tagOptionsHtml,key,fmNs=mw.config.get('wgFormattedNamespaces');namespaceOptionsHtml=' '+mw.message('namespacesall').escaped+' ';namespaceOptionsHtml+=' '+mw.message('blanknamespace').escaped+' ';for(key in fmNs){if(key>0){namespaceOptionsHtml+='<option value="'+key+'">'+fmNs[key]+' ';}}tagOptionsHtml=' '+message('select-placeholder-none').escaped+' ';for(key=0;key<rcTags.length;key++) {tagOptionsHtml+='<option value="'+mw.html.escape(rcTags[key])+'">'+mw.html.escape(rcTags[key])+' ';}$wrapper=$($.parseHTML(' '+' '+message('title').escaped+' ('+appVersion+') '+' '+(!mw.user.isAnon?('<a target="_blank" href="'+mw.util.getUrl('Special:Log',{type:'patrol',user:mw.user.getName,subtype:'patrol'})+'">'+message('mypatrollog').escaped+'</a>'):'')+'<a id="mw-rtrc-toggleHelp">'+message('help').escaped+'</a>'+' '+' '+'<form id="krRTRC_RCOptions" class="mw-rtrc-settings mw-rtrc-nohelp make-switch"> '+' '+' '+' '+message('filter').escaped+' '+' '+' '+'<input type="checkbox" name="hideliu" />'+' '+message('filter-hideliu').escaped+' '+' '+' '+'<input type="checkbox" name="hidebots" />'+' '+message('filter-hidebots').escaped+ ' '+' '+' '+' '+'<input type="checkbox" name="unpatrolled" />'+' '+message('filter-unpatrolled').escaped+' '+' '+' '+message('userfilter').escaped+' : '+'<input type="search" size="16" name="user" />'+' '+' '+' '+' '+' '+message('type').escaped+' '+' '+' '+'<input type="checkbox" name="typeEdit" checked />'+' '+message('typeEdit').escaped+' '+' '+' '+'<input type="checkbox" name="typeNew" checked />'+' '+message('typeNew').escaped+' '+' '+' '+' '+' '+mw.message('namespaces').escaped+' '+'<select class="mw-rtrc-setting-select" name="namespace">'+namespaceOptionsHtml+' '+' '+' '+' '+' '+message('timeframe').escaped+ ' '+' '+' '+' '+message('time-from').escaped+': '+'<input type="text" size="16" placeholder="YYYYMMDDHHIISS" name="start" />'+' '+' '+' '+message('time-untill').escaped+': '+'<input type="text" size="16" placeholder="YYYYMMDDHHIISS" name="end" />'+' '+' '+' '+' '+' '+message('order').escaped+' '+' '+' '+' '+' '+'<input type="radio" name="dir" value="newer" />'+' '+message('asc').escaped+' '+' '+' '+'<input type="radio" name="dir" value="older" checked />'+' '+message('desc').escaped+' '+' '+' '+' '+'<label for="mw-rtrc-settings-refresh" class="head">'+message('reload-interval').escaped+' '+'<span section="Reload_Interval" class="helpicon"> '+ ' '+'<input type="number" value="3" min="0" max="99" size="2" id="mw-rtrc-settings-refresh" name="refresh" />'+' '+' '+'<input class="button" type="button" id="RCOptions_submit" value="'+message('apply').escaped+'" />'+' '+' '+' '+' '+'<label for="mw-rtrc-settings-limit" class="head">'+message('limit').escaped+' '+' <select id="mw-rtrc-settings-limit" name="limit">'+' 10 '+' 25 '+' 50 '+' 75 '+' 100 '+' 250 '+' 500 '+' '+' '+' '+' '+message('tag').escaped+' <select class="mw-rtrc-setting-select" name="tag">'+tagOptionsHtml+' '+' '+' '+' '+' '+message('cvn-scores'). escaped+'<span section="CVN_Scores" class="helpicon"> '+'<input type="checkbox" class="switch" name="cvnDB" />'+' '+' '+(oresModel?(' '+' '+message('ores-scores').escaped+'<span section="ORES_Scores" class="helpicon"> '+'<input type="checkbox" class="switch" name="ores" />'+' '+' '):'')+' '+' '+message('masspatrol').escaped+' '+'<input type="checkbox" class="switch" name="massPatrol" />'+' '+' '+' '+' '+message('autodiff').escaped+' '+'<input type="checkbox" class="switch" name="autoDiff" />'+' '+' '+' '+' '+message('pause').escaped+'<input class="switch" type="checkbox" id="rc-options-pause" />'+' '+' '+' '+' '+'<a name="krRTRC_DiffTop" />'+ '<div class="mw-rtrc-diff mw-rtrc-diff-closed" id="krRTRC_DiffFrame"> '+' '+' '+' '+' '+' '+'<img src="'+ajaxLoaderUrl+'" id="krRTRC_loader" style="display: none;" />'+' '+message('legend').escaped+': '+' '+mw.message('markedaspatrolled').escaped+', '+' '+message('currentedit').escaped+' , '+' '+message('skippededit').escaped+' '+' '+' '+' '+' '+' '+'Real-Time Recent Changes by '+'<a href="//meta.wikimedia.org/wiki/User:Krinkle">Krinkle</a>'+' | <a href="'+docUrl+'">'+message('documentation').escaped+'</a>'+ ' | <a href="https://github.com/Krinkle/mw-gadget-rtrc/releases">'+message('changelog').escaped+'</a>'+' | <a href="https://github.com/Krinkle/mw-gadget-rtrc/issues">'+message('feedback').escaped+'</a>'+' '+' '+' '));$wrapper.find('input.switch').after(' ');$wrapper.find('#krRTRC_DiffFrame').on('click','table.diff a',function{var $el=$(this);if($el.is('[href^="http://"], [href^="https://"], [href^="//"]')){$el.attr('target','_blank');}});$('#content').empty.append($wrapper);$body=$wrapper.find('.mw-rtrc-body');$feed=$body.find('.mw-rtrc-feed');}function annotationsCacheUp(increment){annotationsCacheSize+=increment||1;if(annotationsCacheSize>1000){annotationsCache.patrolled=Object.create(null);annotationsCache.ores=Object.create(null);annotationsCache.cvn=Object.create(null);}}function bindInterface{var api=new mw.Api;$RCOptionsSubmit=$('#RCOptions_submit');$RCOptionsSubmit.on('click',function{$RCOptionsSubmit.prop('disabled',true) .css('opacity','0.5');readSettingsForm;updateFeedNow.then(function{wakeupMassPatrol(opt.app.massPatrol);});return false;});$wrapper.on('click','#diffClose',function{$('#krRTRC_DiffFrame').addClass('mw-rtrc-diff-closed');currentDiff=currentDiffRcid=!1;});$feed.on('click','a.diff',function(e){var $item=$(this).closest('.mw-rtrc-item').addClass('mw-rtrc-item-current'),title=$item.find('.mw-title').text,href=$(this).attr('href'),$frame=$('#krRTRC_DiffFrame');$feed.find('.mw-rtrc-item-current').not($item).removeClass('mw-rtrc-item-current');currentDiff=Number($item.data('diff'));currentDiffRcid=Number($item.data('rcid'));$frame.addClass('mw-rtrc-diff-loading').removeClass('mw-rtrc-diff-newpage mw-rtrc-diff-closed');$.ajax({url:mw.util.wikiScript,dataType:'html',data:{action:'render',diff:currentDiff,diffonly:'1',uselang:conf.wgUserLanguage}}).fail(function(jqXhr){$frame.append(jqXhr.responseText||'Loading diff failed.').removeClass('mw-rtrc-diff-loading');}).done(function( data){var skipButtonHtml,$diff;if(skippedRCIDs.includes(currentDiffRcid)){skipButtonHtml=' <a id="diffUnskip">'+message('unskip').escaped+'</a> ';}else{skipButtonHtml=' <a id="diffSkip">'+message('skip').escaped+'</a> ';}$frame.html(data).prepend(' '+mw.html.escape(title)+' '+' '+' <a id="diffClose">'+message('close').escaped+'</a> '+' <a href="'+href+'" target="_blank" id="diffNewWindow">'+message('open-in-wiki').escaped+'</a> '+(userHasPatrolRight?' <a onclick="(function{ if($(\'.patrollink a\').length){ $(\'.patrollink a\').click; } else { $(\'#diffSkip\').click; } });">[mark]</a> ':'')+' <a id="diffNext">'+mw.message('next').escaped+' »</a> '+skipButtonHtml+' ').removeClass('mw-rtrc-diff-loading');if(opt.app.massPatrol){$frame.find('.patrollink a').click;}else{$diff=$frame.find( 'table.diff');if($diff.length){mw.hook('wikipage.diff').fire($diff.eq(0));}scrollIntoViewIfNeeded($frame);}});e.preventDefault;});$feed.on('click','a.newPage',function(e){var $item=$(this).closest('.mw-rtrc-item').addClass('mw-rtrc-item-current'),title=$item.find('.mw-title').text,href=$item.find('.mw-title').attr('href'),$frame=$('#krRTRC_DiffFrame');$feed.find('.mw-rtrc-item-current').not($item).removeClass('mw-rtrc-item-current');currentDiffRcid=Number($item.data('rcid'));$frame.addClass('mw-rtrc-diff-loading mw-rtrc-diff-newpage').removeClass('mw-rtrc-diff-closed');$.ajax({url:href,dataType:'html',data:{action:'render',uselang:conf.wgUserLanguage}}).fail(function(jqXhr){$frame.append(jqXhr.responseText||'Loading diff failed.').removeClass('mw-rtrc-diff-loading');}).done(function(data){var skipButtonHtml;if(skippedRCIDs.includes(currentDiffRcid)){skipButtonHtml=' <a id="diffUnskip">'+message('unskip').escaped+'</a> ';}else{skipButtonHtml= ' <a id="diffSkip">'+message('skip').escaped+'</a> ';}$frame.html(data).prepend(' '+title+' '+' '+' <a id="diffClose">'+message('close').escaped+'</a> '+' <a href="'+href+'" target="_blank" id="diffNewWindow">'+message('open-in-wiki').escaped+'</a> '+' <a onclick="$(\'.patrollink a\').click">['+message('mark').escaped+']</a> '+' <a id="diffNext">'+mw.message('next').escaped+' »</a> '+skipButtonHtml+' ').removeClass('mw-rtrc-diff-loading');if(opt.app.massPatrol){$frame.find('.patrollink a').click;}});e.preventDefault;});$wrapper.on('click','.patrollink',function{var $el=$(this);$el.find('a').text(mw.msg('markaspatrolleddiff')+'...');api.postWithToken('patrol',{action:'patrol',rcid:currentDiffRcid}).done(function(data){if(!data||data.error){$el.empty.append($(' ').text(mw.msg( 'markedaspatrollederror')));mw.log('Patrol error:',data);return;}$el.empty.append($(' ').text(mw.msg('markedaspatrolled')));$feed.find('.mw-rtrc-item[data-rcid="'+currentDiffRcid+'"]').addClass('mw-rtrc-item-patrolled');annotationsCacheUp;annotationsCache.patrolled[currentDiffRcid]=!0;if(opt.app.autoDiff){nextDiff;}}).fail(function{$el.empty.append($(' ').text(mw.msg('markedaspatrollederror')));});return false;});$wrapper.on('click','#diffNext',function{nextDiff;});$wrapper.on('click','#diffSkip',function{$feed.find('.mw-rtrc-item[data-rcid="'+currentDiffRcid+'"]').addClass('mw-rtrc-item-skipped');skippedRCIDs.push(currentDiffRcid);nextDiff;});$wrapper.on('click','#diffUnskip',function{$feed.find('.mw-rtrc-item[data-rcid="'+currentDiffRcid+'"]').removeClass('mw-rtrc-item-skipped');skippedRCIDs.splice(skippedRCIDs.indexOf(currentDiffRcid),1);});$('#mw-rtrc-toggleHelp').on('click',function(e){e. preventDefault;$('#krRTRC_RCOptions').toggleClass('mw-rtrc-nohelp mw-rtrc-help');});$('.mw-rtrc-settings .helpicon').attr('title',msg('helpicon-tooltip')).click(function(e){e.preventDefault;window.open(docUrl+'#'+$(this).attr('section'),'_blank');});$wrapper.on('click','.mw-rollback-link a',function{$('.patrollink a').click;});$('#rc-options-pause').on('click',function{if(!this.checked){updateFeedNow;return;}clearTimeout(updateFeedTimeout);});}function showUnsupported{$('#content').empty.append($(' ').addClass('errorbox').text('This program requires functionality not supported in this browser.'));}function showFail(errMsg){$('#content').empty.append($(' ').addClass('errorbox').text(errMsg||'An unexpected error occurred.'));}function initData{var promises=[];promises.push(mw.loader.using('mediawiki.user').then(function{return mw.user.getRights.then(function(rights){if(rights.includes('patrol')){userHasPatrolRight=!0;}});}));promises.push(mw.loader.using( 'mediawiki.api').then(function{return new mw.Api.loadMessages(['blanknamespace','contributions','contribslink','diff','markaspatrolleddiff','markedaspatrolled','markedaspatrollederror','namespaces','namespacesall','newpageletter','next','talkpagelinktext']);}));promises.push($.ajax({url:apiUrl,dataType:'json',data:{format:'json',action:'query',list:'tags',tgprop:'displayname'}}).then(function(data){var tags=data.query&&data.query.tags;if(tags){rcTags=tags.map(function(tag){return tag.name;});}}));promises.push($.ajax({url:apiUrl,dataType:'json',data:{format:'json',action:'query',meta:'siteinfo'}}).then(function(data){wikiTimeOffset=(data.query&&data.query.general.timeoffset)||0;}));return $.when.apply(null,promises);}function init{var dModules,dI18N,featureTest,$navToggle,dOres,navSupported=conf.skin==='vector';document.title='RTRC: '+conf.wgDBname;$(function{$('#p-namespaces ul').find('li.selected').removeClass('new').find('a').text('RTRC');});featureTest=!!(Date.parse);if(! featureTest){$(showUnsupported);return;}$('html').addClass('mw-rtrc-available');if(navSupported){$('html').addClass('mw-rtrc-sidebar-toggleable');$(function{$navToggle=$(' ').addClass('mw-rtrc-navtoggle');$('body').append($(' ').addClass('mw-rtrc-sidebar-cover'));$('#mw-panel').append($navToggle).on('mouseenter',function{$('html').addClass('mw-rtrc-sidebar-on');}).on('mouseleave',function{$('html').removeClass('mw-rtrc-sidebar-on');});});}dModules=mw.loader.using(['jquery.client','mediawiki.diff.styles','mediawiki.special.changeslist','mediawiki.jqueryMsg','mediawiki.Uri','mediawiki.user','mediawiki.util','mediawiki.api']);if(!mw.libs.getIntuition){mw.libs.getIntuition=$.ajax({url:intuitionLoadUrl,dataType:'script',cache:!0,timeout:7000});}dOres=$.ajax({url:oresApiUrl,dataType:$.support.cors?'json':'jsonp',cache:!0,timeout:2000}).then(function(data){if(data&&data.models){if(data.models.damaging){oresModel='damaging';}else if(data.models.reverted){oresModel='reverted'; }}},function{return $.Deferred.resolve;});dI18N=mw.libs.getIntuition.then(function{return mw.libs.intuition.load('rtrc');}).then(function{message=mw.libs.intuition.message.bind(null,'rtrc');msg=mw.libs.intuition.msg.bind(null,'rtrc');},function{mw.messages.set('intuition-i18n-gone','$1');message=function(key){return mw.message('intuition-i18n-gone',key);};msg=function(key){return key;};return $.Deferred.resolve;});$.when(initData,dModules,dI18N,dOres,$.ready).fail(showFail).done(function{if($navToggle){$navToggle.attr('title',msg('navtoggle-tooltip'));}monthNames=msg('months').split(',');buildInterface;readPermalink;updateFeedNow;scrollIntoView($wrapper);bindInterface;rAF(function{$('html').addClass('mw-rtrc-ready');});});}$.when(mw.loader.using('mediawiki.util'),$.ready).then(function{if(!$('#t-rtrc').length){mw.util.addPortletLink('p-tb',mw.util.getUrl('Special:BlankPage/RTRC'),'RTRC','t-rtrc','Monitor and patrol recent changes in real-time',null, '#t-specialpages');}if(conf.wgCanonicalSpecialPageName==='Recentchanges'&&!$('#ca-nstab-rtrc').length){mw.util.addPortletLink('p-namespaces',mw.util.getUrl('Special:BlankPage/RTRC'),'RTRC','ca-nstab-rtrc','Monitor and patrol recent changes in real-time');}});if((conf.wgTitle==='Krinkle/RTRC'&&conf.wgAction==='view')||(conf.wgCanonicalSpecialPageName==='Blankpage'&&conf.wgTitle.split('/',2)[1]==='RTRC')){init;}});},{"css":});