• 正在查找将来过去时的官方设定集?不如看看万界大百科吧!
  • 《将来过去时》第一部分 现在 魔科纪元的少年少女 即将正式发布!
  • 让我偷偷看一眼小鱼君的博客……
  • 服务器已成功迁移到 阿里云(杭州)

“MediaWiki:Gadget-NotifyWhenCopy.js”的版本间的差异

来自小鱼君和他的朋友们
(机智的小鱼君移动页面MediaWiki:NotifyWhenCopy.jsMediaWiki:Gadget-NotifyWhenCopy.js
 
(未显示同一用户的28个中间版本)
第1行: 第1行:
 
$(function() {
 
$(function() {
    // Start
+
    mw.loader.load('https://common.wjghj.cn/js/shake');
 +
 
 +
   if (mw.config.get('wgUserGroups').includes('sysop')) return; // 不对管理员生效
 
    (new mw.Api()).get({
 
    (new mw.Api()).get({
 
     action: 'query',
 
     action: 'query',
 
     meta: 'allmessages',
 
     meta: 'allmessages',
     ammessages: 'License-description|Custom-copynotify|Custom-copynotify-'+wgPageName,
+
     ammessages: 'License-description|Copy-notify|Copy-notify/page/'+wgPageName,
 
     amlang: mw.config.get('wgUserLanguage') || mw.config.get('wgContentLanguage')
 
     amlang: mw.config.get('wgUserLanguage') || mw.config.get('wgContentLanguage')
 
    }).done(function(data) {
 
    }).done(function(data) {
 
     // Variables
 
     // Variables
     var license = $('.license-description a').prop('outerHTML'),
+
     var licenseDescriptionMsg = data.query.allmessages[0]['*'],
      licenseDescriptionMsg = data.query.allmessages[0]['*'].replace('$1', license),
 
 
       customMsg = data.query.allmessages[1]['*'],
 
       customMsg = data.query.allmessages[1]['*'],
 
       customPageMsg = data.query.allmessages[2]['*'],
 
       customPageMsg = data.query.allmessages[2]['*'],
第35行: 第36行:
 
     // Output
 
     // Output
 
     $(window).on('copy',function() {
 
     $(window).on('copy',function() {
      toastr['warning'](debugMsg,'')
+
      if ($('.copy-notify').length < 1) {
 +
      ssi_modal.notify('',{
 +
       title: '',
 +
       content: finalMsg,
 +
       closeAfter: {time:60},
 +
       position: 'top center',
 +
       sizeClass: 'full',
 +
       className: 'copy-notify',
 +
       onClose: function() {
 +
        $(window).unbind('scroll');
 +
        $('body').css('margin-top','');
 +
       }
 +
      });
 +
      if($(window).scrollTop() < 1) $('body').css('margin-top',$('.copy-notify').height()+70);
 +
      $(window).bind('scroll',function(){
 +
       console.log($(window).scrollTop());
 +
       if ($(window).scrollTop() < 1) {
 +
        $('body').css('margin-top',$('.copy-notify').height()+70);
 +
       } else {
 +
        $('body').css('margin-top','');
 +
       }
 +
      });
 +
     } else {
 +
      $('.copy-notify').shake(4,10,200);
 +
     }
 
     });
 
     });
+
 
 
    });
 
    });
 
   // End
 
   // End
 
});
 
});

2020年10月5日 (一) 10:47的最新版本

$(function() {
    mw.loader.load('https://common.wjghj.cn/js/shake');

    if (mw.config.get('wgUserGroups').includes('sysop')) return; // 不对管理员生效
    (new mw.Api()).get({
      action: 'query',
      meta: 'allmessages',
      ammessages: 'License-description|Copy-notify|Copy-notify/page/'+wgPageName,
      amlang: mw.config.get('wgUserLanguage') || mw.config.get('wgContentLanguage')
    }).done(function(data) {
      // Variables
      var licenseDescriptionMsg = data.query.allmessages[0]['*'],
          customMsg = data.query.allmessages[1]['*'],
          customPageMsg = data.query.allmessages[2]['*'],
 
          defaultMsg =  '你刚刚复制了<span style="font-weight:bold;">' + wgSiteName + '</span>上的内容!'+ licenseDescriptionMsg + '<br/>转载时请注明出处:<span style="font-style:italic;font-weight:bold;">' + decodeURIComponent(location.href) + '</span>',
 
          finalMsg;
 
      // Get custom messages
      if ( customPageMsg !== undefined && customPageMsg !== '-' && customPageMsg !== '' ) {
        finalMsg = customPageMsg
          .replace( /\$sitename/ig , wgSiteName )
          .replace( /\$url/ig , decodeURIComponent(location.href) )
          .replace( /\$license/ig , licenseDescriptionMsg );
      } else if ( customMsg !== undefined && customMsg !== '-' && customMsg !== '' ) {
        finalMsg = customMsg
          .replace( /\$sitename/ig , wgSiteName )
          .replace( /\$url/ig , decodeURIComponent(location.href) )
          .replace( /\$license/ig , licenseDescriptionMsg );
      } else {
        finalMsg = defaultMsg;
      }
      var debugMsg = 'defaultMsg is:<br/>' + defaultMsg + '<hr/>customMsg is:<br/>' + customMsg + '<hr/>customPageMsg is:<br/>' + customPageMsg + '<hr/>finalMsg is:<br/>' + finalMsg;
 
      // Output
      $(window).on('copy',function() {
        if ($('.copy-notify').length < 1) {
          ssi_modal.notify('',{
            title: '',
            content: finalMsg,
            closeAfter: {time:60},
            position: 'top center',
            sizeClass: 'full',
            className: 'copy-notify',
            onClose: function() {
              $(window).unbind('scroll');
              $('body').css('margin-top','');
            }
          });
          if($(window).scrollTop() < 1) $('body').css('margin-top',$('.copy-notify').height()+70);
          $(window).bind('scroll',function(){
            console.log($(window).scrollTop());
            if ($(window).scrollTop() < 1) {
              $('body').css('margin-top',$('.copy-notify').height()+70);
            } else {
              $('body').css('margin-top','');
            }
          });
        } else {
          $('.copy-notify').shake(4,10,200);
        }
      });

    });
  // End
});