|
|
2行目: |
2行目: |
| // すべての中身をここに入れて動かす | | // すべての中身をここに入れて動かす |
|
| |
|
| // CSSでボタンをデザイン
| |
| toTopButton.css({
| |
| position: 'fixed',
| |
| bottom: '20px',
| |
| right: '20px',
| |
| background: '#555',
| |
| color: '#fff',
| |
| padding: '5px 10px',
| |
| borderRadius: '4px',
| |
| textDecoration: 'none',
| |
| display: 'none', // 初期は非表示
| |
| zIndex: '1000'
| |
| });
| |
|
| |
| // ページに追加
| |
| $('body').append(toTopButton);
| |
|
| |
| // スクロールしたら表示
| |
| $(window).scroll(function() {
| |
| if ($(this).scrollTop() > 200) {
| |
| toTopButton.fadeIn();
| |
| } else {
| |
| toTopButton.fadeOut();
| |
| }
| |
| });
| |
|
| |
| // ボタンクリックでトップに戻る
| |
| toTopButton.click(function() {
| |
| $('html, body').animate({scrollTop:0}, 500);
| |
| return false;
| |
| });
| |
| });
| |
|
| |
| // 外部リンクを新規タブで開く
| |
| $(function() {
| |
| $('a.external').attr('target', '_blank');
| |
| });
| |
|
| |
| // 目次トグル機能追加
| |
| $(function(){
| |
| var toc = $('#toc');
| |
| if(toc.length){
| |
| toc.before('<button id="toggle-toc">目次を開閉</button>');
| |
| $('#toggle-toc').css({
| |
| margin: '5px', padding: '3px 6px', cursor: 'pointer'
| |
| }).click(function(){
| |
| toc.slideToggle();
| |
| });
| |
| }
| |
| });
| |
|
| |
| // 編集リンクをアイコン化
| |
| //$(function() {
| |
| // $('.mw-editsection a').html('<span style="font-size:14px">📝</span>');
| |
| //});
| |
|
| |
| // Lightbox2読み込み
| |
| mw.loader.load('https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.4/js/lightbox.min.js');
| |
| $('head').append('<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.4/css/lightbox.min.css" />');
| |
|
| |
| // 画像にdata-lightbox属性を自動追加
| |
| $(function() {
| |
| $('a.image').each(function() {
| |
| $(this).attr('data-lightbox', 'image-gallery');
| |
| });
| |
| });
| |
|
| |
| // 折りたたみ可能セクション
| |
| $(function() {
| |
| $('.mw-headline').click(function() {
| |
| $(this).parent().nextUntil('h2, h3, h4, h5, h6').slideToggle();
| |
| }).css('cursor', 'pointer');
| |
| });
| |
|
| |
| // リアルタイム時計
| |
| //$(function() {
| |
| // var clock = $('<div id="wiki-clock"></div>').css({
| |
| // position: 'fixed',
| |
| // top: '10px',
| |
| // right: '20px',
| |
| // background: '#333',
| |
| // color: '#fff',
| |
| // padding: '3px 8px',
| |
| // borderRadius: '4px',
| |
| // zIndex: 1000
| |
| // }).appendTo('body');
| |
|
| |
| // function updateClock(){
| |
| // clock.text(new Date().toLocaleString());
| |
| // }
| |
| // setInterval(updateClock, 1000);
| |
| // updateClock();
| |
| //});
| |
|
| |
| // 最近の更新をポップアップ表示
| |
| $(function(){
| |
| var recentBtn = $('<button id="recent-popup">最近の更新</button>').css({
| |
| position: 'fixed', bottom: '50px', right: '20px',
| |
| padding: '5px 10px', background: '#444', color: '#fff', borderRadius: '4px', cursor: 'pointer', zIndex: 1000
| |
| }).appendTo('body');
| |
|
| |
| recentBtn.click(function(){
| |
| window.open(mw.util.getUrl('特別:最近の更新'), 'recentChanges', 'width=800,height=600');
| |
| });
| |
| });
| |
|
| |
| // ユーザー名歓迎表示
| |
| $(function(){
| |
| if(mw.config.get('wgUserName')){
| |
| $('#mw-head').prepend(
| |
| '<div style="padding:5px;background:#1a73e8;color:#fff;text-align:center;">ようこそ、' +
| |
| mw.config.get('wgUserName') + 'さん!</div>'
| |
| );
| |
| }
| |
| });
| |
|
| |
|
| // ユーステラ風✨星キラキラカーソル(頻度調整+水色強化版) | | // ユーステラ風✨星キラキラカーソル(頻度調整+水色強化版) |
148行目: |
33行目: |
| }); | | }); |
| }); | | }); |
|
| |
| // ツールチップ機能
| |
| $(function(){
| |
| $('[data-tooltip]').hover(function(){
| |
| var tooltip = $('<div class="tooltip"></div>').text($(this).attr('data-tooltip')).css({
| |
| position: 'absolute',
| |
| background: '#444',
| |
| color: '#fff',
| |
| padding: '4px 8px',
| |
| borderRadius: '5px',
| |
| zIndex: 1000,
| |
| whiteSpace: 'nowrap'
| |
| }).appendTo('body').hide().fadeIn(200);
| |
|
| |
| $(this).mousemove(function(e){
| |
| tooltip.css({top:e.pageY+10, left:e.pageX+10});
| |
| });
| |
| }, function(){
| |
| $('.tooltip').fadeOut(200,function(){ $(this).remove(); });
| |
| });
| |
| });
| |
|
| |
| // スムーズスクロール
| |
| $(function(){
| |
| $('a[href^="#"]').click(function(e){
| |
| e.preventDefault();
| |
| var target = $(this.hash);
| |
| if(target.length){
| |
| $('html, body').animate({scrollTop:target.offset().top},600);
| |
| }
| |
| });
| |
| });
| |
|
| |
| // 最終更新日の表示
| |
| //$(function(){
| |
| // var lastEdit = $('#footer-info-lastmod').text();
| |
| // $('<div class="last-modified"></div>').text('🕑 ' + lastEdit).css({
| |
| // position:'absolute', top:'5px', right:'5px', padding:'5px 10px',
| |
| // background:'#333', color:'#fff', borderRadius:'5px', zIndex:1000
| |
| // }).prependTo('#mw-content-text');
| |
| //});
| |
|
| |
|
| |
| // 読了時間表示
| |
| $(function(){
| |
| var text = $('#mw-content-text').text();
| |
| var minutes = Math.ceil(text.length / 500); //500文字/分で計算
| |
| $('<div id="read-time">⏳ 読了目安: ' + minutes + '分</div>').css({
| |
| padding: '5px', background: '#e2f0ff', borderRadius: '5px',
| |
| display: 'inline-block', marginBottom: '10px'
| |
| }).prependTo('#mw-content-text');
| |
| });
| |
|
| |
| // スクロール進捗バー
| |
| $(function(){
| |
| var progressBar = $('<div id="progress-bar"></div>').css({
| |
| position:'fixed', top:'0', left:'0', height:'4px',
| |
| background:'#6cf', width:'0%', zIndex:1000
| |
| }).appendTo('body');
| |
|
| |
| $(window).scroll(function(){
| |
| var winScroll = $(window).scrollTop();
| |
| var height = $(document).height() - $(window).height();
| |
| var scrolled = (winScroll / height) * 100;
| |
| progressBar.css('width', scrolled + '%');
| |
| });
| |
| }); | | }); |