From Wikipedia, the free encyclopedia
Content deleted Content added
|
|
|||
| Line 12: | Line 12: | ||
|
function addSuggestionBox(fixed) { |
function addSuggestionBox(fixed) { |
||
|
const container = |
const container = |
||
|
document.querySelector(‘.mw-search- |
document.querySelector(‘.mw-search–‘) || |
||
|
document.querySelector(‘#mw-content-text’); |
document.querySelector(‘#mw-content-text’); |
||
| Line 18: | Line 18: | ||
|
const box = document.createElement(‘div’); |
const box = document.createElement(‘div’); |
||
|
box.style.background = ‘# |
box.style.background = ‘#’; |
||
|
box.style.border=”1px solid # |
box.style.border=”1px solid #”; |
||
|
box.style.padding = ‘ |
box.style.padding = ”; |
||
|
box.style.margin = ‘ |
box.style.margin = ‘ 0’; |
||
|
box.style.fontSize=”15px”; |
box.style.fontSize=”15px”; |
||
|
box.style.borderRadius=” |
box.style.borderRadius=””; |
||
|
box.style.boxShadow = ‘0 1px 2px rgba(0,0,0,0.08)’; |
|||
|
box.style.lineHeight=”1.5″; |
|||
|
const strong = document.createElement(‘b’); |
|||
|
strong.textContent=”Did you mean: “; |
|||
|
const link = document.createElement(‘a’); |
const link = document.createElement(‘a’); |
||
|
link.href = `/w/index.php?title=Special:Search&search=${encodeURIComponent(fixed)}`; |
link.href = `/w/index.php?title=Special:Search&search=${encodeURIComponent(fixed)}`; |
||
|
link.textContent = |
link.textContent = fixed; |
||
|
link.style.fontWeight=”bold”; |
|||
|
link.style.color=”#36c”; |
|||
|
link.style.textDecoration = ‘underline’; |
|||
|
box. |
box.; |
||
|
box.appendChild(link); |
box.appendChild(link); |
||
|
box.appendChild(document.createTextNode(‘ ?’)); |
|||
|
container.prepend(box); |
container.prepend(box); |
||
| Line 37: | Line 44: | ||
|
(function () { |
(function () { |
||
|
// Only |
// Only on Special:Search |
||
|
if (mw.config.get(‘wgCanonicalSpecialPageName’) !== ‘Search’) return; |
if (mw.config.get(‘wgCanonicalSpecialPageName’) !== ‘Search’) return; |
||
| Line 43: | Line 50: | ||
|
const term = params.get(‘search’) || ”; |
const term = params.get(‘search’) || ”; |
||
|
// |
// |
||
|
if (!/[א-ת]/.test(term)) return; |
if (!/[א-ת]/.test(term)) return; |
||
Latest revision as of 21:24, 30 November 2025
// Hebrew → English physical keyboard mapping
const hebToEngMap = {
'ש':'a','נ':'b','ב':'c','ג':'d','ק':'e','כ':'f','ע':'g','י':'h','ח':'i',
'ל':'j','ך':'k','ף':'l','ז':'z','ס':'x','ה':'w','ר':'r','ת':'t','ד':'s',
'ו':'u','ט':'y','א':'t','מ':'n','צ':'m','ם':'o','ן':'i','פ':'p'
};
function convertHebrew(str) {
return str.split('').map(ch => hebToEngMap[ch] || ch).join('');
}
function addSuggestionBox(fixed) {
const container =
document.querySelector('.mw-search-results-info') ||
document.querySelector('#mw-content-text');
if (!container) return;
const box = document.createElement('div');
box.style.background = '#f8f9fa';
box.style.border = '1px solid #c8ccd1';
box.style.padding = '12px 16px';
box.style.margin = '16px 0';
box.style.fontSize = '15px';
box.style.borderRadius = '6px';
box.style.boxShadow = '0 1px 2px rgba(0,0,0,0.08)';
box.style.lineHeight = '1.5';
const strong = document.createElement('b');
strong.textContent = 'Did you mean: ';
const link = document.createElement('a');
link.href = `/w/index.php?title=Special:Search&search=${encodeURIComponent(fixed)}&fulltext=1&ns0=1`;
link.textContent = fixed;
link.style.fontWeight = 'bold';
link.style.color = '#36c';
link.style.textDecoration = 'underline';
box.appendChild(strong);
box.appendChild(link);
container.prepend(box);
}
(function () {
// Only on Special:Search
if (mw.config.get('wgCanonicalSpecialPageName') !== 'Search') return;
const params = new URLSearchParams(window.location.search);
const term = params.get('search') || '';
// Only act on Hebrew terms
if (!/[א-ת]/.test(term)) return;
const fixed = convertHebrew(term);
if (!fixed || fixed === term) return;
addSuggestionBox(fixed);
})();


