MediaWiki:Common.js: Difference between revisions
From LSJ
mNo edit summary |
mNo edit summary |
||
Line 40: | Line 40: | ||
} | } | ||
}); | }); | ||
$( function() { | |||
'use strict'; | |||
$( 'body' ).append( '<span id="to-top">▲ Go to top</span>' ); | |||
var $topButton = $( '#to-top' ); | |||
$topButton.css( { | |||
'color': '#FFF', | |||
'position': 'fixed', | |||
'bottom': '-30px', | |||
'left': '4px', | |||
'cursor': 'pointer', | |||
'transition': 'bottom 0.5s', | |||
'-webkit-transition': 'bottom 0.5s', | |||
'user-select': 'none', | |||
'-webkit-user-select': 'none', | |||
'-moz-user-select': 'none', | |||
'-ms-user-select': 'none' | |||
} ).click( function() { | |||
$( 'html, body' ).animate( { scrollTop: 0 }, 'slow' ); | |||
} ); | |||
$( window ).scroll( function() { | |||
if ( $( window ).scrollTop() > 100 ) { | |||
$topButton.css( 'bottom', '4px' ); | |||
} else { | |||
$topButton.css( 'bottom', '-30px' ); | |||
} | |||
} ); | |||
} ); |
Revision as of 17:29, 8 October 2021
$(document).ready(function() { if(mw.config.get("wgCanonicalNamespace") == "") { var subjectName; var pageName = mw.config.get("wgPageName"); if(pageName.charAt(pageName.length - 1) == ")") { subjectName = pageName.substring(0, pageName.lastIndexOf("(") - 1); } else { subjectName = pageName; } var newNode = " <a href='https://www.google.com/search?q=%22" + encodeURIComponent(subjectName.replace(/_/g, " ")).replace(/'/g,"%27") + "%22 +-lsj.gr +-dge.cchs.csic.es +-enacademic.com +-logeion.uchicago.edu +-perseus.uchicago.edu +-perseus.tufts.edu' target='_blank' rel='noopener, noreferrer, nofollow'><span style='font-size:x-small;'>Search Google</span></a>" $("#firstHeading").append(newNode); } }); $( function () { var elems = document.getElementsByClassName('mw-headline'); for (i = 0; i < elems.length; i++) { var span = document.createElement('span'); span.classList.add('ttop'); var link = document.createElement('a'); link.href = '#top'; link.appendChild(document.createTextNode('back to top')); span.appendChild(document.createTextNode('[')); span.appendChild(link); span.appendChild(document.createTextNode('] ')); elems[i].insertBefore(span, elems[i].firstChild); } }); document.addEventListener("dblclick", function () { var w = String(window.getSelection()); var urlParams = new URLSearchParams(window.location.search); if (w && !mw.config.values.wgUserName){ location.href="https://lsj.gr/index.php?search=" + encodeURIComponent(w); } }); $( function() { 'use strict'; $( 'body' ).append( '<span id="to-top">▲ Go to top</span>' ); var $topButton = $( '#to-top' ); $topButton.css( { 'color': '#FFF', 'position': 'fixed', 'bottom': '-30px', 'left': '4px', 'cursor': 'pointer', 'transition': 'bottom 0.5s', '-webkit-transition': 'bottom 0.5s', 'user-select': 'none', '-webkit-user-select': 'none', '-moz-user-select': 'none', '-ms-user-select': 'none' } ).click( function() { $( 'html, body' ).animate( { scrollTop: 0 }, 'slow' ); } ); $( window ).scroll( function() { if ( $( window ).scrollTop() > 100 ) { $topButton.css( 'bottom', '4px' ); } else { $topButton.css( 'bottom', '-30px' ); } } ); } );