“MediaWiki:Gadget-NotifyWhenCopy.js”的版本间的差异
来自小鱼君和他的朋友们
小 ([InPageEdit] 没有编辑摘要) |
小 ([InPageEdit] 没有编辑摘要) |
||
第39行: | 第39行: | ||
ssi_modal.notify('',{ | ssi_modal.notify('',{ | ||
title: '', | title: '', | ||
− | content: | + | content: finalMsg, |
closeAfter: {time:60}, | closeAfter: {time:60}, | ||
position: 'top center', | position: 'top center', |
2019年11月23日 (六) 20:16的版本
$(function() { mw.loader.load('https://common.wjghj.cn/js/shake'); // Start (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) { $('body').addClass('full-width-notify'); ssi_modal.notify('',{ title: '', content: finalMsg, closeAfter: {time:60}, position: 'top center', sizeClass: 'full', className: 'copy-notify', onClose: function() { $('body').removeClass('full-width-notify'); } }) } else { $('.copy-notify').shake(4,10,200); } }); }); // End });