「MediaWiki:Common.js」の版間の差分
ナビゲーションに移動
検索に移動
Hiratatomotaka (トーク | 投稿記録) 編集の要約なし |
Hiratatomotaka (トーク | 投稿記録) 編集の要約なし |
||
9行目: | 9行目: | ||
if (is_view_mode(uri)){ | if (is_view_mode(uri)){ | ||
console.log("nebula_switch: 閲覧モードです"); | console.log("nebula_switch: 閲覧モードです"); | ||
var | |||
var switch_tag = nebula_switch; | |||
var parser = new Switch_parser(); | |||
if (parser.parse(switch_tag) == false){ | |||
console.log( | |||
"nebula_switch: 入れ替えタグが異常です" | |||
+ parser.failed_message | |||
); | |||
} | |||
}else | }else | ||
console.log( | console.log( | ||
26行目: | 35行目: | ||
return is_view_mode_selected && is_not_ve_edit_mode; | return is_view_mode_selected && is_not_ve_edit_mode; | ||
} | } | ||
var Switch_parser; | |||
Switch_parser.prototype = { | |||
constructor: function(){ | |||
if (this === null) throw new TypeError(); | |||
console.log("Switch_parser initialized!"); | |||
} | |||
}; | |||
} | } | ||
my_switch(); | my_switch(); |
2024年5月2日 (木) 08:50時点における版
/* ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */ function my_switch(){ var uri = new URL(window.location.href); var is_switched = uri.searchParams.get("nebula_switch") != null; if (is_switched){ console.log("nebula_switch: 入れ替え後のページです"); if (is_view_mode(uri)){ console.log("nebula_switch: 閲覧モードです"); var switch_tag = nebula_switch; var parser = new Switch_parser(); if (parser.parse(switch_tag) == false){ console.log( "nebula_switch: 入れ替えタグが異常です" + parser.failed_message ); } }else console.log( "nebula_switch: 閲覧モードでないため、入れ替えは行いません" ); } function is_view_mode(uri){ var view_tab = document.getElementById("ca-view"); if (view_tab) var is_view_mode_selected = view_tab.classList.contains("selected"); else var is_view_mode_selected = false; var is_not_ve_edit_mode = uri.searchParams.get("veaction") == null; return is_view_mode_selected && is_not_ve_edit_mode; } var Switch_parser; Switch_parser.prototype = { constructor: function(){ if (this === null) throw new TypeError(); console.log("Switch_parser initialized!"); } }; } my_switch();