MediaWiki:Edittools.js
From Learning Languages Through Video Games
Jump to navigationJump to searchNote: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
function runFixer(fixer) { var textarea = document.getElementById('wpTextbox1'); if(textarea.selectionStart === undefined) { alert("Looks like the fixers won't work in this browser.\nIf you're running Internet Explorer, well, that's why."); return; } var sel_start = textarea.selectionStart; var sel_end = textarea.selectionEnd; var selected_text = textarea.value.substring(sel_start, sel_end); if(!selected_text) { alert("No text was selected!"); return; } textarea.value = textarea.value.slice(0, sel_start) + fixer(selected_text) + textarea.value.slice(sel_end, -1); } function fixJp(text) { var substitutions = { /か゛/g, 'が', /き゛/g, 'ぎ', /く゛/g, 'ぐ', /け゛/g, 'げ', /こ゛/g, 'ご', /さ゛/g, 'ざ', /し゛/g, 'じ', /す゛/g, 'ず', /せ゛/g, 'ぜ', /そ゛/g, 'ぞ', /た゛/g, 'だ', /ち゛/g, 'ぢ', /つ゛/g, 'づ', /て゛/g, 'で', /と゛/g, 'ど', /は゛/g, 'ば', /ひ゛/g, 'び', /ふ゛/g, 'ぶ', /へ゛/g, 'べ', /ほ゛/g, 'ぼ', /は゜/g, 'ぱ', /ひ゜/g, 'ぴ', /ふ゜/g, 'ぷ', /へ゜/g, 'ぺ', /ほ゜/g, 'ぽ', /カ゛/g, 'ガ', /キ゛/g, 'ギ', /ク゛/g, 'グ', /ケ゛/g, 'ゲ', /コ゛/g, 'ゴ', /サ゛/g, 'ザ', /シ゛/g, 'ジ', /ス゛/g, 'ズ', /セ゛/g, 'ゼ', /ソ゛/g, 'ゾ', /タ゛/g, 'ダ', /チ゛/g, 'ヂ', /ツ゛/g, 'ヅ', /テ゛/g, 'デ', /ト゛/g, 'ド', /ハ゛/g, 'バ', /ヒ゛/g, 'ビ', /フ゛/g, 'ブ', /ヘ゛/g, 'ベ', /ホ゛/g, 'ボ', /ハ゜/g, 'パ', /ヒ゜/g, 'ピ', /フ゜/g, 'プ', /ヘ゜/g, 'ペ', /ホ゜/g, 'ポ', /ウ゛/g, 'ヴ' }; for(x in substitutions) { text = string.replace(substitutions[x], text) } return text; } addOnloadHook(function() { $j('#fixer-jp').append("<input type='button' onclick='runFixer(fixJp)' value='Tempt Fate' />"); });