MediaWiki:UnsupportedTitles.js
Chú ý: Sau khi lưu trang này, phải xóa bộ nhớ đệm (cache) của trình duyệt để những thay đổi hiện ra
- Firefox / Safari: Nhấn giữ phím Shift trong khi nhấn Tải lại (Reload), hoặc nhấn tổ hợp Ctrl-F5 hay Ctrl-R (⌘R trên Mac)
- Google Chrome: Nhấn tổ hợp Ctrl-Shift-R (⇧⌘R trên Mac)
- Internet Explorer / Edge: Nhấn giữ phím Ctrl trong khi nhấn Làm tươi (Refresh), hoặc nhấn tổ hợp Ctrl-F5
- Opera: Nhấn tổ hợp Ctrl-F5.
/*
* On subpages of Tiêu_đề_không_được_hỗ_trợ and Talk:Tiêu_đề_không_được_hỗ_trợ, show the
* correct title in the header at the top of the page. For instance, on the page
* [[Tiêu_đề_không_được_hỗ_trợ/Left curly bracket]], show the title {.
*
* This is not enabled in the mobile version of the site.
*
* For all such pages, see [[Special:PrefixIndex/Tiêu_đề_không_được_hỗ_trợ]].
*/
if (mw.config.get('wgAction') === 'view'
&& /^(?:Talk:)?Tiêu_đề_không_được_hỗ_trợ\//.test(mw.config.get('wgPageName')))
$(function() {
var titleMap = {
'Amp': '&',
'Ampersand_semicolon': '& ;',
'Australian_Aboriginal_Flag_emoticon_alternative' : '[-0-]',
'Australian_Aboriginal_Flag_emoticon' : '[-o-]',
'C_sharp': 'C#',
'C_through_N_to_K': 'C|N>K',
'Cifrão': '[Cifrão]',
'Colon_capital_D': ':D',
'Colon_capital_P': ':P',
'Colon_capital_thorn': ':Þ',
'Colon_equals': ':=',
'Colon_hyphen_capital_D': ':-D',
'Colon_hyphen_capital_P': ':-P',
'Colon_hyphen_capital_thorn': ':-Þ',
'Colon_hyphen_left_curly_bracket': ':-{',
'Colon_hyphen_left_paren': ':-(',
'Colon_hyphen_lowercase_thorn': ':-þ',
'Colon_hyphen_right_paren': ':-)',
'Colon_hyphen_slash': ':-/',
'Colon_hyphen_small_p': ':-p',
'Colon_left_curly_bracket': ':{',
'Colon_left_paren': ':(',
'Colon_lowercase_thorn': ':þ',
'Colon_right_paren': ':)',
'Colon_slash_slash': '://',
'Colon_slash': ':/',
'Colon_small_d': ':d',
'Colon_small_p': ':p',
'Colon_three': ':3',
'Colon': ':',
'': '',
'Curly_brackets': '{ }',
'Double_colon': '::',
'Double_period': '..',
'Enclosing_colons': ': :',
'Enclosing_less_than_greater_than': '< >',
'Enclosing_low_lines': '_ _',
'Enclosing_number_signs': '# #',
'Enclosing_vertical_lines': '| |',
'End_s_tag': '</s>',
'eq_number_sign': 'eq #',
'Equal_greater_than': '=>',
'Equal_less_than': '=<',
'f_double_number_sign_k': 'f##k',
'f_double_number_sign_ked': 'f##ked',
'f_double_number_sign_king': 'f##king',
'f_double_number_sign_ks': 'f##ks',
'Full_stop': '.',
'g_tag': '<g>',
'Greater_than_equal': '>=',
'Greater_than_low_line_less_than': '>_<',
'Greater_than': '>',
'hr_number_sign': 'hr #',
'HTML_comment': '<!-- -->',
'HTML_start_tag_end_tag': '< > </ >',
'Hyphen_greater_than': '->',
'Hyphen_vertical_line_vertical_line_hyphen' : '-||-',
'Ideographic_space': '[ideographic space]',
'Left_curly_bracket': '{',
'Left_square_bracket': '[',
'Less_than_equal': '<=',
'Less_than_greater_than': '<>',
'Less_than_hyphen': '<-',
'Less_than_slash_three': '</3',
'Less_than_three': '<3',
'Less_than_trailing_slash_greater_than': '< />',
'Less_than': '<',
'Low_line_interfix': '-_-',
'Low_line': '_',
'MeToo': '#MeToo',
'MeTooed': '#MeTooed',
'MeTooing': '#MeTooing',
'MeToos': '#MeToos',
'Nine_low_line_nine': '9_9',
'Number_sign': '#',
'Ogham_space': '[Ogham space]',
'Old_Israeli_shekel': '[Old Israeli shekel]',
'Ornate_parentheses': '﴾ ﴿',
'Period_slash_period': './.',
'Replacement_character': '\uFFFD',
'Right_curly_bracket': '}',
'Right_square_bracket': ']',
'S:t_Michel': 'S:t Michel',
'Semicolon': ';',
'Space': '[space]',
'Square_bracketed_citation_needed': '[citation needed]',
'Square_bracketed_ellipsis': '[…]',
'Square_brackets': '[ ]',
'Vertical_line_vertical_line': '||',
'Vertical_line': '|',
'Ancient_Greek_dish': 'λοπαδο\u00ADτεμαχο\u00ADσελαχο\u00ADγαλεο'
+ '\u00ADκρανιο\u00ADλειψανο\u00ADδριμυ\u00ADποτριμματο\u00AD'
+ 'σιλφιο\u00ADκαραβο\u00ADμελιτο\u00ADκατακεχυμενο\u00AD'
+ 'κιχλε\u00ADπικοσσυφο\u00ADφαττο\u00ADπεριστερα\u00AD'
+ 'λεκτρυο\u00ADνοπτο\u00ADκεφαλλιο\u00ADκιγκλο\u00AD'
+ 'πελειο\u00ADλαγῳο\u00ADσιραιο\u00ADβαφητραγανοπτερύγων',
'Thai_name_of_Bangkok': 'กรุงเทพมหานคร อมรรัตนโกสินทร์ มหินทรายุธยา มหาดิลกภพ นพรัตนราชธานีบูรีรมย์ อุดมราชนิเวศน์มหาสถาน อมรพิมานอวตารสถิต สักกะทัตติยวิษณุกรรมประสิทธิ์',
'о_slash_dot': 'о/.'
};
/*
To get template for titleTag.textContent, process MediaWiki:pagetitle,
open your browser's JavaScript console on a Wiktionary page
and run this code:
((msg) => new mw.Api().getMessages(msg).then((messages) => {
mw.messages.set(messages);
const titleTemplate = new mw.Message(mw.messages, msg, ["$1"]).text();
const {
before,
after
} = /^(?<before>.*)\$1(?<after>.*)/.exec(titleTemplate).groups;
console.log(before, after)
})
.fail(console.error))("pagetitle")
We can do this for action=edit and action=submit by replacing
"pagetitle" with "editing" in this snippet.
*/
function setTitle(newTitle) {
// Set title tag, which determines the title shown in the browser.
var titleTag = document.getElementsByTagName('title')[0];
titleTag.textContent = newTitle + " - Wiktionary tiếng Việt";
// Set the text of the first heading above the page content.
document.getElementById('firstHeading').textContent = newTitle;
}
try {
var subpage = /^(?:Talk:)?Tiêu_đề_không_được_hỗ_trợ\/(.+)$/
.exec(mw.config.get('wgPageName'))[1];
var newTitle = titleMap[subpage] || subpage;
if (mw.config.get('wgCanonicalNamespace') == 'Talk')
newTitle = 'Talk:' + newTitle;
setTitle(newTitle);
} catch (e) {
console.log('Lỗi khi sửa tiêu đề: ' + e.message + '.');
}
});
/*
* This redirects a user to the correct Unsupported titles page if they attempt
* to access an invalid title. For instance, if you attempt to access the page
* for <
* https://en.wiktionary.org/wiki/%3C
* you will be redirected to
* https://vi.wiktionary.org/wiki/Unsupported_titles/Less_than
*/
if (mw.config.get('wgCanonicalSpecialPageName') == 'Badtitle') {
/*
* Get the name of the page that the user attempted to access using either
* the portion of the URL after "/wiki/" or the value of the "title"
* parameter in the query. That is, the user is accessing the page using
* either the path /wiki/<invalid title> or a path similar to
* /w/index.php?title=<invalid title>.
*
* The actual page displayed if a user attempts to access an invalid title
* is the special page with the canonical title [[Special:Badtitle]].
*/
var rxArticlePath = new RegExp('^' + mw.config.get('wgArticlePath').replace('$1', '(.*)') + '$');
var m = rxArticlePath.exec(location.pathname);
var title = m ? decodeURIComponent(m[1]) : mw.util.getParamValue('title');
// Not all titles are listed, because not all actually trigger the "bad title" message.
var revTitleMap = {
'<': 'Less than',
'>': 'Greater than',
'{': 'Left curly bracket',
'}': 'Right curly bracket',
'[': 'Left square bracket',
']': 'Right square bracket',
'_': 'Low line',
' ': 'Space',
':': 'Colon',
'.': 'Full stop',
'|': 'Vertical line',
'||': 'Vertical line vertical line',
'| |': 'Enclosing vertical lines',
'::': 'Double colon',
': :': 'Enclosing colons',
'<>': 'Less than greater than',
'< >': 'Enclosing less than greater than',
'<3': 'Less than three',
'<g>': 'g tag',
'< > </ >': 'HTML start tag end tag',
'[ ]': 'Square brackets',
'{ }': 'Curly brackets',
'C|N>K': 'C through N to K',
'\uFFFD': 'Replacement character',
'-||-' : 'Hyphen vertical line vertical line hyphen'
};
if (revTitleMap[title]) {
location.href = mw.util.getUrl('Tiêu đề không được hỗ trợ/' + revTitleMap[title]);
}
}