Benutzer:Prog/js

Aus Wikibooks
Zur Navigation springen Zur Suche springen

// var progcoder = {}; window.progcoder = progcoder; // // $(function(){ if($.inArray(mw.config.get('wgAction'), ['view', 'purge']) == -1) return; var box = $('#JSExtensionToolBox'); if(!box.length){ box = $('<div id="JSExtensionToolBox" />'); box.insertBefore('#firstHeading'); } box.append( '<div class="JSPurgeLinkBox"><a class="JSPurgeLink" href="'+mw.config.get('wgServer')+mw.config.get('wgScript')+ '?title='+encodeURIComponent(mw.config.get('wgPageName'))+'&action=purge">purge</a></div>' ); var css = mw.util.addCSS( '.JSPurgeLink {margin:0px 5px}'+ '#JSExtensionToolBox {text-align:right;font-size:0.8em;}' ); }); // // $(function(){ if(mw.config.get('wgNamespaceNumber') != -1) return; $('#mw-content-text li[class]').attr('class', function(i, v){ var find = /(watchlist[-][0-9]+)/; var res = find.exec(v); if(res) return v + ' watchlist ' + res[1]; return v; }); mw.util.addCSS( '.watchlist { border-width:1px; border-left-width:8px; border-bottom-width:3px; border-style:solid; padding:1px 3px; margin:0px; }'+ '.watchlist-0 { border-color:#FF0000; }'+ // Kapitel '.watchlist-1 { border-color:#FF8080; }'+ // Kapitel Diskussion '.watchlist-2 { border-color:#FFFF00; }'+ // Benutzer '.watchlist-3 { border-color:#FFFF80; }'+ // Benutzer Diskussion '.watchlist-4 { border-color:#80FF00; }'+ // Wikibooks '.watchlist-5 { border-color:#80FF80; }'+ // Wikibooks Diskussion '.watchlist-6 { border-color:#0080FF; }'+ // Datei '.watchlist-7 { border-color:#0080C0; }'+ // Datei Diskussion '.watchlist-8 { border-color:#FF8000; }'+ // MediaWiki '.watchlist-9 { border-color:#FF8040; }'+ // MediaWiki Diskussion '.watchlist-10 { border-color:#804000; }'+ // Vorlage '.watchlist-11 { border-color:#808000; }'+ // Vorlage Diskussion '.watchlist-12 { border-color:#FF00FF; }'+ // Hilfe '.watchlist-13 { border-color:#FF80FF; }'+ // Hilfe Diskussion '.watchlist-14 { border-color:#808080; }'+ // Kategorie '.watchlist-15 { border-color:#C0C0C0; }'+ // Kategorie Diskussion '.watchlist-102 { border-color:#80FFFF; }'+ // Regal '.watchlist-103 { border-color:#00FFFF; }' // Regal Diskussion ); }); // // (function($, pc){ var loadedList = new mw.Map(); $.extend(pc, {userInfo: function(name, container){ if(false) return; if(typeof name != 'string') return; var box = $('<div class="JSUserInfoBox" style="position:relative;" />'); container.append(box); if(loadedList.exists(name)){ var element = loadedList.get(name); if($.isArray(element)){ element.push(box); }else{ box.append(element.clone()); } }else{ loadedList.set(name, [box]); var url = mw.config.get('wgServer')+mw.config.get('wgScriptPath')+ "/api.php?action=query&format=json&list=users&ususers="+name+"&usprop=blockinfo|groups|editcount|registration|gender"; var completeRequest = function(json){ var inner = $(document.createElement('div')); inner.addClass('JSUserInfoInner'); inner.append('<div class="JSUserInfoHeadline"></div>'); var user = json.query.users[0]; if(user.missing) inner.append('<div><b>User is missing</b></div>'); else inner.append('<div><b>Name</b>: ' + user.name + '</div>'); if(user.registration) inner.append('<div><b>Registration</b>: ' + user.registration + '</div>'); if(user.groups) inner.append('<div><b>Groups</b>: ' + user.groups.join(', ') + '</div>'); if(user.editcount) inner.append('<div><b>Edits</b>: ' + user.editcount + '</div>'); if(user.gender) inner.append('<div><b>Gender</b>: ' + user.gender + '</div>'); if(user.blockedby) inner.append('<div><b>Blocked by</b> ' + user.blockedby + '</div>'); if(user.blockreason) inner.append('<div><b>Block reason</b>: ' + user.blockreason + '</div>'); if(user.blockexpiry) inner.append('<div><b>Block expiry</b>: ' + user.blockexpiry + '</div>'); var elements = loadedList.get(name); for(var i = 0; i < elements.length; ++i){ elements[i].append(inner.clone()); } loadedList.set(name, inner); }; $.getJSON(url, completeRequest); } }}); }(jQuery, progcoder)); // // $(function(){ if($.inArray(mw.config.get('wgAction'), ['view', 'purge']) == -1) return; if($.inArray(mw.config.get('wgNamespaceNumber'), [2, 3]) == -1) return; var box = $('#JSExtensionToolBox'); if(!box.length){ box = $('<div id="JSExtensionToolBox" />'); box.insertBefore('#firstHeading'); } var pagename = mw.config.get('wgPageName'); var part = /[:]([^\/:]+)/.exec(pagename); if(!part) return; var username = part[1]; var server = mw.config.get('wgServer'); var path = mw.config.get('wgArticlePath'); var namespaces = mw.config.get('wgFormattedNamespaces'); box.prepend( $('<div class="JSUserPageLinkBox" />').append( '<a class="JSUserPageLink" href="'+ server+path.replace('$1', namespaces[2]+':'+username)+'">'+username+'</a>', '<a class="JSUserPageLink" href="'+ server+path.replace('$1', namespaces[3]+':'+username)+'">Talk</a>', '<a class="JSUserPageLink" href="'+ server+path.replace('$1', namespaces[-1]+':Contributions/'+username)+'">Contributions</a>', '<a class="JSUserPageLink" href="https://tools.wmflabs.org/supercount/index.php?user='+ username+'&project='+mw.config.get('wgContentLanguage')+'.'+mw.config.get('wgSiteName')+'">Info</a>', '<a class="JSUserPageLink" href="http://toolserver.org/~vvv/sulutil.php?user='+ username+'">SUL</a>' ) ); var headline = $('<div class="JSUserPageInfoHeadline"><span>↴ </span>user info</div>'); var content = $('<div class="JSUserPageInfoContent" style="display:none;position:absolute;right:0;z-index:1;"/>'); headline.one('click', function(){progcoder.userInfo(username, content);}); headline.click(function(){content.toggle();}); box.prepend($('<div class="JSUserPageInfoBox" />').append(headline, content)); var css = mw.util.addCSS( '.JSUserPageLink {margin:0px 5px}'+ '.JSUserPageInfoContent {text-align:left;background-color:#fff;border:1px solid black;padding:3px;}'+ '.JSUserPageInfoHeadline {font-weight:bold;}'+ '#JSExtensionToolBox {text-align:right;font-size:0.8em;}' ); }); // // $(function(){ $('#bodyContent a').each(function(){ var user = $(this).attr('title'); var namespaces = mw.config.get('wgFormattedNamespaces'); var part = (new RegExp(namespaces[2] + '[:]([^/:]+)$')).exec(user); if(!part) return; var username = part[1]; username = username.replace(/ \([^()]+\)$/, ''); var box = $('<div class="JSUserInlineInfoBox" style="display:inline-block;position:relative;" />'); var headline = $('<div class="JSUserInlineInfoHeadline">↴</div>'); var content = $('<div class="JSUserInlineInfoContent" style="display:none;position:absolute;z-index:1;" />'); box.append(headline, content); var server = mw.config.get('wgServer'); var path = mw.config.get('wgArticlePath'); var talk = $('<a class="JSUserPageLink" href="'+server+path.replace('$1', namespaces[3] + ":")+username+'">Talk</a>'); var contributions = $('<a class="JSUserPageLink" href="'+server+path.replace('$1', namespaces[-1] + ":")+'Contributions/'+username+'">Contributions</a>'); content.append(talk, contributions); headline.one('click', function(){progcoder.userInfo(username, content);}); headline.click(function(){content.toggle();}); $(this).after(box); var css = mw.util.addCSS( '.JSUserPageLink {margin:0px 5px}'+ '.JSUserInlineInfoContent {text-align:left;background-color:rgb(255, 255, 255);border:1px solid black;padding:3px;}'+ '.JSUserInlineInfoHeadline {font-weight:bold;}' ); }); }); //