User:Danke7/global.js

importScriptPage('Usuario:Danke7/wikia.js', 'es.comunidad');

/* Created by User:Grunny, modify by User:Cizagna */ (function($){if(typeof window.grQuickAdopt!=='undefined'){return false;} window.grQuickAdopt={version:'0.1',init:function{if(wgCanonicalSpecialPageName==='Contributions'){var $qaLink=$('').attr('title',grQuickAdopt.langMsg('adopt-tooltip')).attr('style','cursor: pointer').text(grQuickAdopt.langMsg('adopt-link-text')).click(grQuickAdopt.quicklyAdopt);$('#contentSub > a:last').after(' | ',$qaLink);}},langConfig:{userLang:false,es:{'adopt-reason':'Adoptando el wiki','adopt-tooltip':'Da a este usuario el cargo de Administrador','adopt-link-text':'QAdopt','adopt-success-text':'Adopción exitosa'}},langMsg:function(name){if(grQuickAdopt.langConfig.userLang&&wgUserLanguage in grQuickAdopt.langConfig&&name in grQuickAdopt.langConfig[wgUserLanguage]){return grQuickAdopt.langConfig[wgUserLanguage][name];} if(wgContentLanguage in grQuickAdopt.langConfig&&name in grQuickAdopt.langConfig[wgContentLanguage]){return grQuickAdopt.langConfig[wgContentLanguage][name];} return grQuickAdopt.langConfig.es[name];},quicklyAdopt:function{var quickRightsUser=$('input[name="target"]').val,addRights='sysop',rightsReason=grQuickAdopt.langMsg('adopt-reason'),tokenUrl=wgServer+wgScriptPath+'/api.php?action=query&list=users&ususers='+encodeURIComponent(quickRightsUser)+'&ustoken=userrights&format=json';$.getJSON(tokenUrl,function(data){var urToken=data.query.users[0].userrightstoken,rightsChangeUrl=wgServer+wgScriptPath+'/api.php?action=userrights&user='+encodeURIComponent(quickRightsUser) +'&add='+addRights+'&reason='+encodeURIComponent(rightsReason)+'&format=json&token='+encodeURIComponent(urToken);$.post(rightsChangeUrl,function{$('#contentSub').after(' '+grQuickAdopt.langMsg('adopt-success-text')+' ');grQuickAdopt.checkIfUserPageExists;});});},checkIfUserPageExists:function{var checkingUrl=wgServer+wgScriptPath+'/api.php?action=query&prop=revisions&meta=siteinfo&titles=User:'+wgUserName+'&format=json';$.getJSON(checkingUrl,function(data){for(var p in data.query.pages){break;} if(p!=='-1'){return false;} grQuickAdopt.getEditToken;});},getEditToken:function{var editTokenUrl=wgServer+wgScriptPath+'/api.php?action=query&prop=info|revisions&intoken=edit&titles=Main%20Page&format=json',editSummary='Creando página de usuario',editPageName='User:'+wgUserName;if(!window.grUserPageText){return false;} $.getJSON(editTokenUrl,function(data){for(var p in data.query.pages){break;} var editToken=data.query.pages[p].edittoken;grQuickAdopt.makeAPIEdit(editPageName,editSummary,grUserPageText,editToken);});},makeAPIEdit:function(editPageName,editSummary,editContent,editToken){$.ajax({url:wgScriptPath+'/api.php?',data:'action=edit&title='+encodeURIComponent(editPageName)+'&summary='+encodeURIComponent(editSummary) +'&text='+encodeURIComponent(editContent)+'&format=json&token='+encodeURIComponent(editToken),dataType:'json',type:'POST',success:function(data){if(data.edit.result==='Success'){var editId=data.edit.newrevid;$('div.successbox').append(' Página de usuario a sido creada');}else{alert('Error: Resultado API desconocido.');}},error:function(xhr){alert('Error: Edición fallida.');}});}};$(document).ready(grQuickAdopt.init);})(jQuery);