User:Awinkler3/common.js

var authors = { loadinganimation : 0, execute : function { if (mw.config.get('wgArticleId') == 0) return; // no deleted articles if (mw.config.get('wgRevisionId') != 0 && mw.config.get('wgCurRevisionId') != mw.config.get('wgRevisionId')) return; // only current revision $(" von ... ").insertBefore(document.getElementById("contentSub") || document.getElementById("mw-content-text")); loadinganimation = window.setInterval( function { if ($("#authorsloading").html == ". ") $("#authorsloading").html(" . "); else if ($("#authorsloading").html == " . ") $("#authorsloading").html("  ."); else $("#authorsloading").html(".  "); }, 300); mw.loader.load("//wikihistory.toolforge.org/wiki/getauthors.php?wiki=" + window.location.hostname.split(".", 1)[0] + "wiki&page_id=" + mw.config.get('wgArticleId')); }, resultloaded : function( res, old ) { $("#authorsresult").html(res); if (old == 1) mw.loader.load("//wikihistory.toolforge.org/wiki/getauthors.php?wiki=" + window.location.hostname.split(".", 1)[0] + "wiki&page_id=" + mw.config.get('wgArticleId') + '&onlynew=1'); }, stoploading : function { clearInterval(loadinganimation); $('#authorsloading').remove; } } if ( mw.config.get('wgNamespaceNumber') == 0 && ((typeof WikiHistory === 'undefined' || WikiHistory == "all" || WikiHistory == "view") && mw.config.get('wgAction') == "view" || (typeof WikiHistory !== 'undefined' && (WikiHistory == "all" || WikiHistory == "info")) && mw.config.get('wgAction') == "info") ) $( authors.execute );

// $.when(   $.ready,    mw.loader.using( [ "mediawiki.util", "oojs-ui-core", "oojs-ui-widgets" ] ) ).then( function  {    $( "span.mw-headline" ).each( function  { var popup = null; $( this ).after( " ", $( "", { "class": "copy-section-link-pilcrow" } )               .text( "¶" )                .click( function  { if( popup === null ) { var hash = $( this ).prev.attr( "id" ); var oldid = mw.util.getParamValue( "oldid" ); var popupContent; function makeContent( pageName, id ) { var wikitext = (pageName + "#" + hash).replace( /_/g, " " ); if( !window.copySectionLinkNoSquareBrackets ) { wikitext =  + wikitext + ; }                           return $( ' ', { "class": "copy-section-link-content" } ).append(                                $( " ", { "id": "copy-section-wikilink" + id } ).text( wikitext ),                                $( " " )                                    .text( "Copy" )                                    .css( { "padding": "0.5em", "cursor": "pointer", "margin-left": "0.5em" } )                                    .click( function  { var textField = $( this ).prev; try { navigator.clipboard.writeText( textField.text ); } catch( e ) { textField.select; document.execCommand( "copy" ); }                                   } ),                                $( " " ),                                $( "" )                                	.attr( "href", mw.util.getUrl( pageName ) + "#" + encodeURIComponent( hash ) )                                	.text( "external" )                            ); }

var generalCss = { 'font-size': '0.9rem', 'font-family': 'sans-serif' };

var index; if( oldid ) { popupContent = makeContent( "Special:Permalink/" + oldid ); popupContent.css( generalCss ); popupContent.css( { 'padding-top': '0.5em', 'font-weight': 'normal' } ); } else { var normalPanel = new OO.ui.TabPanelLayout( 'normal', {                               label: 'Link',                                $content: makeContent( mw.config.get( 'wgPageName' ), 'normal' )                            } ); var permalinkPanel = new OO.ui.TabPanelLayout( 'permalink', {                               label: 'Permalink',                                $content: makeContent( 'Special:Permalink/' + mw.config.get( 'wgCurRevisionId' ), 'permalink' )                            } ); index = new OO.ui.IndexLayout; index.addTabPanels( [ normalPanel, permalinkPanel ] ); popupContent = index.$element; }                       popup = new OO.ui.PopupWidget( {                            $content: popupContent,                            $floatableContainer: $( this ),                            padded: true,                            width: 400,                            height: 190,                            align: 'forwards',                        } ); $( this ).after( popup.$element ); if( index ) { index.$menu.find( 'span.oo-ui-labelElement-label' ).css( generalCss ); index.$content.css( generalCss ); }

popup.toggle( true ); } else { popup.toggle; }               } ) );    } );    mw.util.addCSS( "h2 .copy-section-link-pilcrow," + "h3 .copy-section-link-pilcrow," + "h4 .copy-section-link-pilcrow," + "h5 .copy-section-link-pilcrow," + "h6 .copy-section-link-pilcrow" + "{ display: none }" + "h2:hover .copy-section-link-pilcrow," + "h3:hover .copy-section-link-pilcrow," + "h4:hover .copy-section-link-pilcrow," + "h5:hover .copy-section-link-pilcrow," + "h6:hover .copy-section-link-pilcrow" + "{ display: inline }" ); } ); //