(新文「→此之JavaScript將載於全簿之頁。: mw.loader.using(['mediawiki.util'], function() { document.querySelector('input#searchInput').addEventListener('input', function() { $(this).trigger('keypress'); }); }); var sectionCJK = { type: 'booklet', label: 'CJK', pages: { 'Punct': { layout: 'characters', label: '、。〃', characters: [' ', '、', '。', '〃', '〄', '々', '〆', '〇', '〈', '〉', '《', '》', '「', '……」) |
無編輯摘要 |
||
(多作未示之審有二次修訂) | |||
第一行: | 第一行: | ||
/* 此之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); | |||
}); | |||
} | |||
var applyDarkMode = function() { | |||
if(window.matchMedia && document.body) { | |||
var match = window.matchMedia('(prefers-color-scheme: dark)'); | |||
if(match.matches) { | |||
document.body.classList.add('dark-mode'); | |||
} | |||
match.addEventListener('change', function(event) { | |||
var darkMode = event.matches; | |||
document.body.classList.toggle('dark-mode', darkMode); | |||
}); | |||
} | |||
}; | |||
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'); | ||
}); | }); | ||
applyDarkMode(); | |||
window.addEventListener('load', applyDarkMode); | |||
}); | }); | ||
var sectionCJK = { | var sectionCJK = { | ||
type: 'booklet', | type: 'booklet', | ||
label: ' | label: ' 漢', | ||
pages: { | pages: { | ||
'Punct': { | 'Punct': { | ||
第三二行: | 第九三行: | ||
$textarea.wikiEditor('addToToolbar', { | $textarea.wikiEditor('addToToolbar', { | ||
'sections': { | 'sections': { | ||
' | 'CJK': sectionCJK | ||
} | } | ||
}); | }); | ||
}); | }); |
二〇二四年八月七日 (三) 〇三時五一分之今審
/* 此之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); }); } var applyDarkMode = function() { if(window.matchMedia && document.body) { var match = window.matchMedia('(prefers-color-scheme: dark)'); if(match.matches) { document.body.classList.add('dark-mode'); } match.addEventListener('change', function(event) { var darkMode = event.matches; document.body.classList.toggle('dark-mode', darkMode); }); } }; mw.loader.using(['mediawiki.util'], function() { addToggleFeature('hangul'); addToggleFeature('kaeriten'); document.querySelector('input#searchInput').addEventListener('input', function() { $(this).trigger('keypress'); }); applyDarkMode(); window.addEventListener('load', applyDarkMode); }); 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 } }); });