User:WiTo7946/common.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
// harv sfn error 來源: User:Sanmosa/HarvErrors.js
error = " <strong class=error>哈佛引用格式錯誤:此sfn模板連結並未指向任何有效引用。</strong>";
jQuery(document).ready(function($) {
links = document.links;
for (i=0; i < links.length; i++)
{
href = links[i].getAttribute('href');
if (href.indexOf('#CITEREF') == 0)
if (document.getElementById(href.substring(1)) == null)
links[i].parentNode.innerHTML += error;
}
});
//條目評級小工具 來源: User:Chiefwei/rater
// [[User:Chiefwei/rater]],作者:[[:en:User:Kephir/gadgets/rater]]
importScript('User:Chiefwei/rater/rater-t.js');
// 實時編輯衝突提示 User:Bluedeck/haystack/edit-conflict
/*實時編輯衝突提示*/
mw.loader.load("User:Bluedeck/serve/edit-conflict.js");
//來源:[[User:滥权管理员/来源折叠]] and modified ver.
importStylesheet( 'User:燃灯/foldRef.css' );
$(function() {
var currentToFoldElement;
// for article space only
if (mw.config.get('wgNamespaceNumber') !== 0) {
return;
}
var viewPortHeight = window.innerHeight;
// target at the following classes / IDs
var toFold = $('.reflist, .refbegin, #references-NoteFoot');
for (i = 0; i < toFold.length; i++){
currentToFoldElement = $(toFold[i]);
// if greater than 90% of the viewport height, fold the references list
if (currentToFoldElement.height() > viewPortHeight * 0.5) {
foldRef(currentToFoldElement);
}
}
// for articles using <references /> without {{reflist}}-like templates
toFold = $('ol.references');
for (i = 0; i < toFold.length; i++){
currentToFoldElement = $(toFold[i]);
if (currentToFoldElement.parent('div').parent('div').hasClass('rd-ref-folded') ||
currentToFoldElement.parent('div').hasClass('rd-ref-folded') ||
currentToFoldElement.parent('div').hasClass('reflist')) {
continue;
}
// if greater than 90% of the viewport height, fold the references list
if (currentToFoldElement.height() > viewPortHeight * 0.5) {
foldRef(currentToFoldElement);
}
}
// attach event listener to the expand buttons
$('.rd-ref-expand-button').click( function(){
$(this).prev('.rd-ref-folded').removeClass('rd-ref-folded');
$(this).remove();
});
});
// create a div, place the reflists inside
function foldRef(currentToFoldElement) {
var newRefFolder = $('<div class="rd-ref-folded"></div>');
newRefFolder.insertBefore(currentToFoldElement);
currentToFoldElement.appendTo(newRefFolder);
// add an expand button at the bottom
newRefFolder.after('<div class="rd-ref-expand-button">展開</div>');
}