User:T45614631/common.js

注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ 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:Xiplus/js/bulletin-editor
importScript('User:Xiplus/js/bulletin-editor.js');

//藍桌圖書館快線 User:Bluedeck/haystack/blib-link
importScript("User:Bluedeck/serve/blib-link.js");

//藍桌圖書館獲取源碼工具 User:Bluedeck/haystack/blib-inverse
importScript("user:bluedeck/serve/blib-inverse.js");

//HotCat-zh+ User:YFdyh000/HotCat-zh-plus.js
mw.loader.load('https://cdn.jsdelivr.net/npm/[email protected]/HotCat-zh-plus.js');

//noteTA動態預覽 User:SunAfterRain/js/noteTA.js
//importScript('User:SunAfterRain/js/noteTA.js');

//noteTA動態預覽inVector User:SunAfterRain/js/noteTAvector.js
//importScript('User:SunAfterRain/js/noteTAvector.js');

//條目評級小工具 User:YFdyh000/RATER
importScript('User:YFdyh000/rater.js');

// 實時編輯衝突提示 User:Bluedeck/haystack/edit-conflict
/*實時編輯衝突提示*/
mw.loader.load("User:Bluedeck/serve/edit-conflict.js");

//來源:[[User:滥权管理员/来源折叠]] and modified ver.
importStylesheet( 'User:T45614631/barn/icon.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>');
}