「MediaWiki:Common.js」の版間の差分

提供:sufeeWiki
ナビゲーションに移動 検索に移動
編集の要約なし
編集の要約なし
 
(同じ利用者による、間の46版が非表示)
1行目: 1行目:
/* ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */
/* ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */
mw.loader.using( ['mediawiki.util'], function () {
mw.loader.using(['mediawiki.util'], function (){
function addInitialize(){
function pageConfig(){
const body = document.getElementsByTagName("body")[0];
function addInitialize(){
const bodyScript_data = {
const body = document.getElementsByTagName("body")[0];
"id":"myScript-mw-script",
try{
"element":"div",
const bodyScript_data = {
"display":"none",
"id":"myScript-mw-script",
"element":"div",
"display":"none",
};
const bodyScript = document.createElement(bodyScript_data.element);
bodyScript.id = bodyScript_data.id;
bodyScript.style.display = bodyScript_data.display;
body.appendChild(bodyScript);
}catch(err){
console.log(err);
}
try{
const bodyCSS_data = {
"id":"myScript-mw-css",
"element":"div",
"display":"none",
};
const bodyCss = document.createElement(bodyCSS_data.element);
bodyCss.id = bodyCSS_data.id;
bodyCss.style.display = bodyCSS_data.display;
body.appendChild(bodyCss);
}catch(err){
console.log(err);
}
}
function getList(doc){
try{
const item = [];
if(doc != null){
const temp = doc.getElementsByTagName("li");
if(temp != null){
for(var i = 0 , l = temp.length;i < l;i++){
item[i] = temp[i];
}
}
}
if(item.length >= 1){
return item;
}
return null;
}catch(err){
console.log(err);
return null;
}
}
}
const bodyScript = document.createElement(bodyScript_data.element);
bodyScript.id = bodyScript_data.id;
addInitialize();
bodyScript.style.display = bodyScript_data.display;
const addScriptFile = getList(document.getElementById("Script-files"));
body.innerHTML += bodyScritpt;
const addCSSFile = getList(document.getElementById("CSS-files"));
}
if(addScriptFile != null){
function getList(doc){
const mw_script = document.getElementById("myScript-mw-script");
const item = [];
for(var i = 0,l = addScriptFile.length;i < l; i++){
if(doc != undefined){
var scriptElement = document.createElement("script");
const temp = doc.getElementsByTagName("li");
if(addScriptFile[i].type == "file"){
for(let index in temp){
scriptElement.src = addScriptFile[i].innerText;
item.push(temp[index]);
}else if(addScriptFile[i].type == "inner"){
scriptElement.innerHTML = addScriptFile[i].innerText;
}else{
scriptElement.src = addScriptFile[i].innerText;
}
mw_script.appendChild(scriptElement);
}
}
}
}
if(item.length >= 1){
if(addCSSFile != null){
return item;
const mw_css = document.getElementById("myScript-mw-css");
for(var i = 0,l = addCSSFile.length;i < l; i++){
var css = document.createElement("link");
if(addCSSFile[i].type == "file"){
css.href = addCSSFile[i].innerText;
css.rel = "stylesheet";
}else if(addCSSFile[i].type == "inner"){
css.innerHTML = addCSSFile[i].innerText;
}else{
css.href = addCSSFile[i].innerText;
css.rel = "stylesheet";
}
mw_css.appendChild(css);
}
}
}
return null;
}
}
addInitialize();
function left_action(){
const addScriptFile = getList(document.getElementById("Script-files"));
const panel = document.getElementById("mw-panel");
const addCSSFile = getList(document.getElementById("CSS-files"));
const div = document.createElement("div");
if(addScriptFile != null){
div.className = "promotion";
div.innerHTML = '<a href="https://twitter.com/real_sufee?ref_src=twsrc%5Etfw" class="twitter-follow-button" data-show-screen-name="false" data-lang="ja" data-show-count="false"> <i></i> </a><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>'
panel.appendChild(div);
}
}
left_action();
pageConfig();
});
});

2022年1月27日 (木) 21:15時点における最新版

/* ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */
mw.loader.using(['mediawiki.util'], function (){
	function pageConfig(){
		function addInitialize(){
			const body = document.getElementsByTagName("body")[0];
			try{
				const bodyScript_data = {
					"id":"myScript-mw-script",
					"element":"div",
					"display":"none",
				};
				const bodyScript = document.createElement(bodyScript_data.element);
				bodyScript.id = bodyScript_data.id;
				bodyScript.style.display = bodyScript_data.display;
				body.appendChild(bodyScript);
			}catch(err){
				console.log(err);
			}
			try{
				const bodyCSS_data = {
					"id":"myScript-mw-css",
					"element":"div",
					"display":"none",
				};
				const bodyCss = document.createElement(bodyCSS_data.element);
				bodyCss.id = bodyCSS_data.id;
				bodyCss.style.display = bodyCSS_data.display;
				body.appendChild(bodyCss);
			}catch(err){
				console.log(err);
			}
		}
		function getList(doc){
			try{
				const item = [];
				if(doc != null){
					const temp = doc.getElementsByTagName("li");
					if(temp != null){
						for(var i = 0 , l = temp.length;i < l;i++){
							item[i] = temp[i];
						}
					}
				}
				if(item.length >= 1){
					return item;
				}
				return null;
			}catch(err){
				console.log(err);
				return null;
			}
		}
		
		addInitialize();
		const addScriptFile = getList(document.getElementById("Script-files"));
		const addCSSFile = getList(document.getElementById("CSS-files"));
		if(addScriptFile != null){
			const mw_script = document.getElementById("myScript-mw-script");
			for(var i = 0,l = addScriptFile.length;i < l; i++){
				var scriptElement = document.createElement("script");
				if(addScriptFile[i].type == "file"){
					scriptElement.src = addScriptFile[i].innerText;
				}else if(addScriptFile[i].type == "inner"){
					scriptElement.innerHTML = addScriptFile[i].innerText;
				}else{
					scriptElement.src = addScriptFile[i].innerText;
				}
				mw_script.appendChild(scriptElement);
			}
		}
		if(addCSSFile != null){
			const mw_css = document.getElementById("myScript-mw-css");
			for(var i = 0,l = addCSSFile.length;i < l; i++){
				var css = document.createElement("link");
				if(addCSSFile[i].type == "file"){
					css.href = addCSSFile[i].innerText;
					css.rel = "stylesheet";
				}else if(addCSSFile[i].type == "inner"){
					css.innerHTML = addCSSFile[i].innerText;
				}else{
					css.href = addCSSFile[i].innerText;
					css.rel = "stylesheet";
				}
				mw_css.appendChild(css);
			}
		}
	}
	
	function left_action(){
		const panel = document.getElementById("mw-panel");
		const div = document.createElement("div");
		div.className = "promotion";
		div.innerHTML = '<a href="https://twitter.com/real_sufee?ref_src=twsrc%5Etfw" class="twitter-follow-button" data-show-screen-name="false" data-lang="ja" data-show-count="false"> <i></i> </a><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>'
		panel.appendChild(div);
	}
	left_action();
	pageConfig();
});