細無編輯摘要 |
無編輯摘要 |
||
第一行: | 第一行: | ||
/* 此之JavaScript將載於全簿之頁。 */ | /* 此之JavaScript將載於全簿之頁。 */ | ||
var removeToggleMenu = function(featureName) { | |||
var menu = document.querySelector('a.toggle-' + featureName); | |||
menu && menu.parentNode.removeChild(menu); | |||
} | |||
var applyToggleMenu = function(featureName) { | |||
var menu = document.querySelector('a.toggle-' + featureName); | |||
if(!menu) return; | |||
var url = new URL(location.href); | |||
url.searchParams.set(featureName, 'toggle'); | |||
menu.href = url.href; | |||
} | |||
var applyToggleFeature = function(featureName) { | |||
var localStorage = window.localStorage; | |||
var url = new URL(location.href); | |||
var urlParam = url.searchParams.get(featureName); | |||
var lsParam = localStorage && localStorage.getItem(featureName); | |||
var use = urlParam || lsParam || 'false'; | |||
if(urlParam == 'toggle') { | |||
use = lsParam == 'false' ? 'true' : 'false'; | |||
url.searchParams.set(featureName, use); | |||
location.href = url.href; | |||
} | |||
if(use == 'true') { | |||
document.body.classList.add('use-' + featureName); | |||
} | |||
if(use == 'false') { | |||
document.body.classList.remove('use-' + featureName); | |||
} | |||
localStorage && localStorage.setItem(featureName, use); | |||
}; | |||
var addToggleFeature = function(featureName) { | |||
applyToggleFeature(featureName); | |||
window.addEventListener('load', function() { | |||
applyToggleFeature(featureName); | |||
}); | |||
applyToggleMenu(featureName); | |||
window.addEventListener('load', function() { | |||
applyToggleMenu(featureName); | |||
}); | |||
} | |||
mw.loader.using(['mediawiki.util'], function() { | mw.loader.using(['mediawiki.util'], function() { | ||
addToggleFeature('hangul'); | |||
addToggleFeature('kaeriten'); | |||
document.querySelector('input#searchInput').addEventListener('input', function() { | document.querySelector('input#searchInput').addEventListener('input', function() { | ||
$(this).trigger('keypress'); | $(this).trigger('keypress'); |
二〇二四年四月一一日 (四) 一一時五五分審
/* 此之JavaScript將載於全簿之頁。 */ var removeToggleMenu = function(featureName) { var menu = document.querySelector('a.toggle-' + featureName); menu && menu.parentNode.removeChild(menu); } var applyToggleMenu = function(featureName) { var menu = document.querySelector('a.toggle-' + featureName); if(!menu) return; var url = new URL(location.href); url.searchParams.set(featureName, 'toggle'); menu.href = url.href; } var applyToggleFeature = function(featureName) { var localStorage = window.localStorage; var url = new URL(location.href); var urlParam = url.searchParams.get(featureName); var lsParam = localStorage && localStorage.getItem(featureName); var use = urlParam || lsParam || 'false'; if(urlParam == 'toggle') { use = lsParam == 'false' ? 'true' : 'false'; url.searchParams.set(featureName, use); location.href = url.href; } if(use == 'true') { document.body.classList.add('use-' + featureName); } if(use == 'false') { document.body.classList.remove('use-' + featureName); } localStorage && localStorage.setItem(featureName, use); }; var addToggleFeature = function(featureName) { applyToggleFeature(featureName); window.addEventListener('load', function() { applyToggleFeature(featureName); }); applyToggleMenu(featureName); window.addEventListener('load', function() { applyToggleMenu(featureName); }); } mw.loader.using(['mediawiki.util'], function() { addToggleFeature('hangul'); addToggleFeature('kaeriten'); document.querySelector('input#searchInput').addEventListener('input', function() { $(this).trigger('keypress'); }); }); var sectionCJK = { type: 'booklet', label: '漢', pages: { 'Punct': { layout: 'characters', label: '、。〃', characters: [' ', '、', '。', '〃', '〄', '々', '〆', '〇', '〈', '〉', '《', '》', '「', '」', '『', '』', '【', '】', '〒', '〓', '〔', '〕', '〖', '〗', '〘', '〙', '〚', '〛', '〜', '〝', '〞', '〟', '〠', '〡', '〢', '〣', '〤', '〥', '〦', '〧', '〨', '〩', '〪', '〫', '〬', '〭', '〮', '〯', '〰', '〱', '〲', '〳', '〴', '〵', '〶', '〷', '〸', '〹', '〺', '〻', '〼', '〽'] }, 'IDC': { layout: 'characters', label: '⿰⿱⿻', characters: ['⿰', '⿱', '⿲', '⿳', '⿴', '⿵', '⿶', '⿷', '⿸', '⿹', '⿺', '⿻'] }, 'Kanbun': { layout: 'characters', label: '㆑㆒㆓', characters: ['㆐', '㆑', '㆒', '㆓', '㆔', '㆕', '㆖', '㆗', '㆘', '㆙', '㆚', '㆛', '㆜', '㆝', '㆞', '㆟'] } } } mw.hook('wikiEditor.toolbarReady').add(function($textarea) { $textarea.wikiEditor('addToToolbar', { 'sections': { 'CJK': sectionCJK } }); });