Pengguna:Hippietrail/custom.js
Catatan: Selepas menyiarkan perubahan, anda mungkin perlu memintas cache pelayar untuk melihatnya.
- Firefox / Safari: Tahan Shift sambil mengklik Reload, atau tekan sama ada Ctrl-F5 atau Ctrl-R (⌘-R pada Mac)
- Google Chrome: Tekan Ctrl-Shift-R (⌘-Shift-R pada Mac)
- Internet Explorer / Edge: Tahan Ctrl sambil mengklik Refresh, atau tekan Ctrl-F5
- Opera: Tekan Ctrl-F5.
/* [[WT:PREFS]]-specific cookie handling
*
* Warning: The numbers associated with each preference must not be changed.
* (The cookie that stores preferences is written as a sequence of preference
* values without the corresponding preference names.) */
/*
* "checkbox" prefs can be used with getCookie() or wiktGetPrefCookie()
* "externcheckbox" prefs can only be used with wiktGetPrefCookie()
* wiktGetPrefCookie() is defined here in custom.js
* so any prefs which need to work without custom.js enabled must use "externcheckbox"
*/
/* TODO OK and Cancel checkboxs. don't write the prefs to the actual cookie
* TODO until OK is clicked
* TODO clearly and discoverably link between these prefs and the standard
* TODO MediaWiki prefs
* TODO clearly indicate the differences between "cookie prefs" and real
* TODO (ie MediaWiki) prefs
* TODO wrap everything in a class with as few globals as possible
* TODO use cirwin's Preferences object from editor.js
* TODO allow external and subprefs to have their own subprefs
*/
// TODO should not be global
var prefs = {
// MASTER SWITCH
WiktionaryUseJSPreferences: {
num: 1,
text: 'Use the preferences set on this page'
},
WiktionaryPreferencesHideSister: {
num: 2,
text: 'Hide the boxes that link to Wikipedia.',
css: [ {
selector: '#bodyContent .sister-project',
declarations: 'display: none;'
} ]
},
WiktionaryPreferencesSmallRC: {
num: 3,
text: 'Make the second half of the heading of Special:RecentChanges smaller',
css: [
{ selector: '#bodyContent .minifont', declarations: 'font-size: 75%;' }
]
},
WiktCustomTopToolbar: {
num: 4,
text: 'Add more script pages to the "Special characters" section of the enhanced editing toolbar',
js: [
{ page: 'Pengguna:Bequw/CustomToolbar.js' }
]
},
WiktionaryPreferencesHideRankings: {
num: 5,
text: 'Hide the boxes containing word frequency rankings.',
css: [
{ selector: '#rank', declarations: 'display: none' }
]
},
WiktRMTbotEntries: {
num: 6,
text: 'Add "[check]" buttons to the end of tbot entry boxes, to remove the template.',
js: [
{ page: 'User:Yair rand/checktbotentries.js' }
]
},
WiktionaryPreferencesHideLinesBetweenLanguages: {
num: 7,
text: 'Hide the horizontal separator between each language section.',
css: [
{ selector: '.ns-0 #bodyContent hr', declarations: 'visibility: hidden' }
]
},
WiktionaryPreferencesHideTranslations: {
num: 8,
text: 'Hide the translation sections entirely. [Instead of having them shown collapsed]',
css: [
{ selector: '#bodyContent .translations', declarations: 'display:none' }
]
},
WiktionaryPreferencesBoxedInflections: {
num: 9,
text: 'Highlight the inflection line of some entries',
css: [
{ selector: '#bodyContent .infl-inline', declarations: 'background-color: #ADFFD6' }
]
},
WiktionaryPreferencesIndentSeeAlso: {
num: 10,
text: 'Indent the “See also” lines more than usual.',
css: [ {
selector: '#bodyContent .disambig-see-also, #bodyContent .disambig-see-also-2',
declarations: 'text-indent: 4em'
} ]
},
WiktionaryPreferencesHideSiteNotice: {
num: 11,
text: 'Hide the display of site-wide notices at the top of the screen.',
css: [
{ selector: '#siteNotice, #fundraiser, .fundraiser-box', declarations: 'display: none;' }
]
},
WiktionaryPrefBoldCitedTerms: { // was CiteTab a long time ago
num: 12,
text: 'Display words in quotations that have been emboldened with {{q}} with a square box instead',
css: [
{ selector: '.citedterm', declarations: 'border:#333 1px solid; padding: 1px 2px; margin: -2px 0px;font-weight: normal;'}
]
},
WiktEditSectionWTEDIT: {
num: 13,
text: 'Edit sections with WT:EDIT, without going to the edit screen. (buggy)',
js: [
{ page: 'Pengguna:Yair rand/editsection.js' }
]
},
WiktionaryPreferencesTime: {
num: 14,
text: 'Show a clock in the top right corner of the screen.',
js: [
{ page: 'Pengguna:Connel_MacKenzie/clock.js' }
]
},
WiktionaryPreferencesPopUps: {
num: 15,
text: 'Use [[:en:w:User:Lupin/popups.js]] to provide page previews and useful checkboxes when hovering on a normal link.',
js: [
{ page: 'User:Lupin/popups.js', wiki: 'en.wikipedia.org' },
{ page: 'Pengguna:Connel_MacKenzie/mess-with-popups.js' }
]
},
WiktionaryPreferencesKeyPad: {
num: 16,
text: 'Show a special character input (like the one beneath the edit field) for the search field. [Does not work in Vector or IE]',
js: [
{ page: 'Pengguna:Connel_MacKenzie/keypad.js' }
]
},
WiktPrefConnelReformat: {
num: 17,
text: 'Use [[User:Connel_MacKenzie/reformat.js]] to reformat pages semi-automatically. [Do NOT use this unless you know Wiktionary policy better than the back of your hand.]',
js: [
{ page: 'User:Connel_MacKenzie/reformat.js' }
]
},
WiktPrefPatrol: {
num: 18
},
WiktPrefDelCmnt: {
num: 19,
text: 'Replace text in deletion log comment',
js: [
{ page: 'Pengguna:Connel_MacKenzie/del-cmnt.js' }
]
},
WiktOrangeLinks: {
num: 20,
text: "Color links to language sections that don't exist orange where they would otherwise be blue (deprecated; use OrangeLinks gadget from Preferences).",
js: [
{ page: 'User:Yair rand/orangelinks2.js' }
],
isdisabled: function() { return wiktGetPrefCookie('WiktOrangeLinks') != 'true'; }
},
// was WiktIrc a very long time ago…
WiktMakeRedLinksBlack: {
num: 21,
text: 'Make red-links on some inflection tables look black.',
css: [
{ selector: '.inflection-table a.new', declarations: 'color: #000000;' }
]
},
WiktAjaxTransLinks: {
num: 22,
text: 'Color translation links orange instead of blue if the target language is missing on an existing page (deprecated; use OrangeLinks gadget from Preferences).',
js: [
{ page: 'User:Hippietrail/ajaxtranslinks.js' }
],
isdisabled: function() { return wiktGetPrefCookie('WiktAjaxTransLinks') != 'true'; }
},
WiktAddStructure: {
num: 23,
text: 'Use [[User:Conrad.Irwin/parser.js]] to provide two different views of most pages.',
js: [
{ page: 'User:Conrad.Irwin/parser.js' }
]
},
WiktHideLogo: {
num: 24,
text: 'Hide the logo in the upper left corner.',
css: [
{ selector: '#p-logo', declarations: 'display: none;' },
{ selector: '#column-one', declarations: 'padding-top: 0;' },
{ selector: '#mw-panel', declarations: 'top:0 !important;' }
]
},
WiktFormOfPlain: {
num: 25,
text: 'Show “form of” definitions with a plain (only wikilinked) lemma. (Default is with a bold lemma.)',
css: [ {
selector: '.use-with-mention .mention',
declarations: 'font-weight: normal !important;'
} ]
},
WiktFormOfItalicQualifier: {
num: 26,
text: 'Show “form of” definitions with an italic definition (“qualifier”) and plain (only wikilinked) lemma. (Default is with a bold lemma.)',
css: [ {
selector: '.use-with-mention',
declarations: 'font-style: italic;'
}, {
selector: '.use-with-mention .mention',
declarations: 'font-weight: normal !important;'
} ]
},
WiktFormOfItalicLemma: {
num: 27,
text: 'Show “form of” definitions with an italic lemma. (Default is with a bold lemma.)',
css: [ {
selector: '.use-with-mention .mention',
declarations: 'font-style: italic !important; font-weight: normal !important;'
} ]
},
WiktFormOfItalicQualifierBoldLemma: {
num: 28,
text: 'Show “form of” definitions with an italic definition (“qualifier”) and bold lemma. (Default is with a bold lemma.)',
css: [
{ selector: '.use-with-mention', declarations: 'font-style: italic;' }
]
},
WiktInterwikiWatchlists: {
num: 29,
text: 'Enable interwiki watchlists.',
js: [
{ page: 'Pengguna:Yair rand/superwatchlist.js' }
]
},
WiktDefEditOptions2: {
num: 30,
text: 'Enable definition editing options.',
js: [
{ page: 'Pengguna:Yair rand/editor2.js' }
]
},
WiktWatchlistNotifications: {
num: 31,
text: 'Enable watchlist notifications.',
js: [
{ page: 'Pengguna:Yair rand/watchlistnotifications.js' }
]
},
WiktLatnMentionBold: {
text: 'Show other Latin (Roman) script mentions in bold. (Default is in italics.)',
num: 32,
css: [ {
selector: '.mention-Latn',
declarations: 'font-style: normal !important; font-weight: bold;'
} ]
},
WiktMentionGlossSingleQuotes: {
num: 33,
text: 'Papar padanan kata/gloss bahasa Melayu untuk istilah yang dinyatakan dalam petikan tunggal. (Default is in double quotes.)',
js: [
{ page: 'Pengguna:Bequw/singleQuote.js' }
]
},
WiktionaryPreferencesHideQualifierParens: {
num: 34,
text: 'Hide the parentheses around list item qualifiers.',
css: [ {
selector: '#bodyContent .qualifier-brac',
declarations: 'display:none' }
]
},
WiktionaryPreferencesItalicParens: {
num: 35,
text: 'Italicize the punctuation (parentheses and colon) around italic text.',
css: [ {
selector: '.ib-brac, .ib-comma, .sense-qualifier-colon',
declarations: 'font-style: italic'
} ]
},
WiktRTRC: {
num: 36,
text: 'Enable Real Time Recent Changes (Documentation at [[m:User:Krinkle/Tools/Real-Time Recent Changes]])',
js: [ // [[File:Krinkle_RTRC.js]] (tracker)
{ page: 'User:Krinkle/RTRC.js', wiki: 'meta.wikimedia.org' }
]
},
WiktHideTrGlossParens: {
num: 37,
text: 'Hide parentheses around transliterations and glosses.',
css: [ {
selector: '.term-tr-gloss-paren, .term-tr-paren, .term-gloss-paren',
declarations: 'display: none'
} ]
},
WiktHideAllParens: {
num: 38,
text: 'Hide the maximal amount of parentheses. [Can cause sentences to appear ungrammatical]',
css: [ {
selector: '.ib-brac, .term-tr-gloss-paren, .term-gloss-paren',
declarations: 'display:none'
} ]
},
WiktHideGlossParens: {
num: 39,
text: 'Hide parentheses around glosses.',
js: [
{ page: 'Pengguna:Bequw/HideGlossParens.js' }
]
},
WiktPlainTransliterations: {
num: 40,
text: 'Show parenthesized plain (non-italic) transliterations.',
css: [ {
selector: '.mention-tr-paren, .mention-tr',
declarations: 'font-style:normal !important'
} ]
},
WiktIrc2: {
num: 41,
text: 'Show a link to a web-based IRC client in the top right-hand corner.',
js: [
{ page: 'Pengguna:Connel_MacKenzie/irc.js' }
]
},
WiktFilterContributions: {
num: 42,
text: 'Filter out your own contributions from Special:Contributions',
js: [
{ page: 'User:Hippietrail/filtercontribs.js' }
]
},
WiktCIDRRangeContribs: {
num: 43,
text: 'Adds a CIDR Range Contributions check to Special:User contributions',
js: [
{ page: 'User:TheDaveRoss/CIDR.js' }
]
},
WiktSidebarTranslation: {
num: 44,
text: 'Translate sidebar interwiki links to English',
js: [
{ page: 'MediaWiki:Gadget-WiktSidebarTranslation.js' }
]
},
WiktWikilook: {
num: 45,
text: 'Enable Wikilook.',
js: [
{ page: 'MediaWiki:WiktionaryLookup-external-bookmarklet.js', wiki:'en.wikinews.org' }
]
},
WiktBlockedNotice: {
num: 46,
text: 'Add a box to the top of user-related pages if the user is blocked from editing. (deprecated; use the BlockInfo gadget in [[Special:Preferences]])',
isdisabled: function() { return wiktGetPrefCookie('WiktBlockedNotice') != 'true'; },
js: [
{ page: 'User:Conrad.Irwin/isblocked.js' }
]
},
// This is just to allow people to test easily
WiktAddProminentInterwikis: {
num: 47,
text: 'Show an interwiki link under the language heading when one exists in the sidebar.',
js: [
{ page: 'User:Conrad.Irwin/iwiki.js' }
]
},
WiktFloatNavToggleLeft: {
num: 48,
text: 'Put the [show] checkbox onto the left of the translation bars.',
css: [ {
selector: '.NavToggle',
declarations: 'float: left !important; position: static !important; right: inherit; margin-top: 0.1em; margin-right: 5px;'
} ]
},
WiktFastBrowse: {
num: 49,
text: 'Browse (faster?) by loading content from the API.',
js: [
{ page: 'User:Yair rand/fastbrowsing.js' }
]
},
WiktPreviewRightTOCs: {
num: 50,
text: 'Put the table of contents onto the right of entries.',
css: [ {
selector: '.ns-0 #toc',
declarations: 'float: right; clear: right; margin-left: 7px; margin-bottom: 6px; display: inline;'
} ]
},
WiktAccelerateFormCreation: {
num: 51,
text: 'Add accelerated creation links for common inflections of some words.',
js: [
{ page: 'User:Conrad.Irwin/creation.js' },
]
},
WiktAssistedEditing: {
num: 52,
text: 'Add input boxes to pages to assist with adding translations.',
js: [
{ page: 'Pengguna:Conrad.Irwin/editor.js' }
]
},
// hide EditTools under search field
WiktionaryPreferencesEditTools: {
num: 53,
text: 'Hide the special character input beneath the edit field.',
css: [
{ selector: '.mw-editTools', declarations: 'display: none;' }
]
},
// Show links to previous and next pages
WiktNearbyPages: {
num: 54,
text: 'Add links to previous and next pages.',
js: [
{ page: 'Pengguna:Hippietrail/nearbypages.js' }
]
},
// Add some per-language toys
WiktPerLanguage: {
num: 55,
text: 'For each language section add interwiki and random links.',
js: [
{ page: 'Pengguna:Hippietrail/perlanguage.js' }
]
},
WiktMoveWasWotdUp: {
num: 56,
text: 'Move the was-WOTD template back to the absolute top-right position (vector).',
css: [
{ selector: '.was-wotd', declarations: 'float:none !important; clear:none !important; position:absolute !important; top: -35px !important; right: 0px !important; margin:0 0 0 0 !important;' }
]
},
WiktSearchKeyboard: {
num: 57,
text: 'Add a button next to the search box to simplify inputting special characters.',
js: [
{ page: 'User:Yair rand/keyboards.js' }
]
},
// hide annoying copyright stuff
WiktHideCopyrightWarning: {
num: 58,
text: 'Hide the copyright warning in the edit window.',
css: [
{ selector: '#editpage-copywarn, .mw-tos-summary', declarations: 'display:none;' }
]
},
WiktAllowDoubleClickLookup: {
num: 59,
text: 'Allow lookup of unlinked words on double click.',
js: [
{ page: 'MediaWiki:Lookup.js' }
]
},
WiktBeerParlourArchiver: {
num: 60,
text: 'Add Archive links to Beer parlour sections.',
js: [
{ page: 'User:Conrad.Irwin/beerArchiver.js',
condition: function () { return wgPageName == 'Wiktionary:Beer_parlour'; }
}
]
},
WiktEtylAlwaysLink: {
num: 61,
text: 'Always linkify language-names in etymologies.',
js: [
{ page: 'User:Ruakh/WiktEtylAlwaysLink.js'
}
]
},
WiktTabbedLanguages: {
num: 62
},
WiktIPAConversion: {
num: 63,
text: 'Allow conversion of IPA to other formats.',
js: [
{ page: 'User:Atelaes/pronunciationCustomization.js'
}
]
},
WiktTargetTrans: {
num: 64
},
WiktRoundBullets4Lists: {
num: 65,
text: 'Change the bullets in unordered lists to be round.',
css: [
{ selector: 'ul', declarations: 'list-style-image:none; list-style-type:disc;' }
]
},
WiktMobile: {
num: 66,
text: 'Customize site for mobile browsers.',
js: [
{ page: 'User:Bequw/mobile.js' }
]
},
WiktUsexEditor: {
num: 67,
text: 'Enable example sentence editor.',
js: [
{ page: 'User:Yair_rand/usexeditor.js' }
]
},
WiktAddDefButton: {
num: 68
},
WiktBCAD: {
num: 69,
text: 'Switch BCE/CE to BC/AD.',
js: [
{ page: 'User:Bequw/bc-ad.js' }
]
},
WiktWSEdit: {
num: 70,
text: 'Enable Wikisaurus editor.',
js: [
{ page: 'User:Yair_rand/wsedit.js' }
]
},
WiktLogoTiles: {
num: 71,
text: 'Use the "tiles" logo. (File:WiktionaryEn.svg)',
css: [ {
selector: '#p-logo a',
declarations: 'background: url(http://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/WiktionaryEn.svg/136px-WiktionaryEn.svg.png) 35% 50% no-repeat !important;' /*
adapted from http://en.wiktionary.org/w/index.php?title=Wiktionary_talk%3AVotes%2F2010-02%2FAccepting_the_results_of_the_Wiktionary_logo_vote&action=historysubmit&diff=8965712&oldid=8739636 */
} ]
},
WiktHeadersInline: {
num: 72,
text: 'Display headers inline.',
css: [
{ selector: '.ns-0 h3, .ns-0 h4, .ns-0 #bodyContent h5', declarations: 'float:left;margin-top:8px;padding-right:5px;padding-top:0px;font-weight:normal;' },
{ selector: '.ns-0 h3:after, .ns-0 h4:after, .ns-0 #bodyContent h5:after', declarations: 'content:":";' },
{ selector: '.ns-0 h3 .editsection, .ns-0 h4 .editsection, .ns-0 h5 .editsection', declarations: 'position:absolute;right:0px;' },
{ selector: '.ns-0 h3+*, .ns-0 h4+*, .ns-0 h5+*', declarations: 'clear:left;' },
{ selector: '.ns-0 h3+p, .ns-0 h4+p, .ns-0 h5+p', declarations: 'clear:none;margin:0px;padding-top:8px;' },
{ selector: '.ns-0 h3+p+*, .ns-0 h4+p+*, .ns-0 h5+p+*', declarations: 'clear:left;' }
]
},
WiktDefEditOptions: {
num: 73
} ,
WiktLangNameISOCodeConverter: {
num: 74,
text: 'Add a language name to ISO code converter to the sidebar.',
js: [
{ page: 'User:Yair rand/languagenametocode.js' }
]
} ,
WiktRhymeEditor: {
num: 75
} ,
WiktYRTabbedLanguages: {
num: 76
} ,
WiktSideTabbedLanguages: {
num: 77 ,
text: 'Tabbed browsing of language sections with tabs on the side.',
js: [
{ page: 'User:Yair_rand/TabbedLanguages2.js' }
]
},
WiktInterwikiWatchlists2: {
num: 78,
text: 'Interwiki watchlists, other version. (Only works with enhanced recent changes.)',
js: [
{ page: 'User:Yair rand/superwatchlist2.js' }
]
},
WiktXTE: {
num: 79,
text: 'Membolehkan Lanjutan Eksperimen Penterjemah.',
js: [
{ page: 'Pengguna:Kephir/gadgets/xte.js' }
]
},
WiktFindTrans: {
num: 80
}
};
/* Warning: The numbers associated with each preference must not be changed.
* (The cookie that stores preferences is written as a sequence of preference
* values without the corresponding preference names.) */
// TODO should not be global
var wiktTempCookie = '';
// this function must be global. it is used from other scripts
// including User:Connel_MacKenzie/clock.js
function wiktGetPrefCookie(wiktPrefName) {
//When we have a few hundred prefs, I’ll have to do this in binary, instead of text "0" & "1"
wiktTempCookie = jQuery.cookie('WiktPrefs') || "";
var prefArray = wiktTempCookie.split("-");
if (jQuery.cookie(wiktPrefName) == 'true') return 'true';
if (wiktPrefName in prefs && prefArray[prefs[wiktPrefName].num]) {
if (prefArray[prefs[wiktPrefName].num] == 1) {
return 'true';
} else return 'false';
} else {
return jQuery.cookie(wiktPrefName) || "";
}
}
function wiktSetPrefCookie(prefName, boolValue) {
wiktTempCookie = jQuery.cookie('WiktPrefs') || "";
var prefArray = wiktTempCookie.split("-");
var versi = "0.1" + "-";
var intValue = 0;
if (boolValue == 'true') intValue = 1;
if (prefs[prefName]) {
prefArray[prefs[prefName].num] = intValue;
} else {
jQuery.cookie(prefName, boolValue, { expires: 30 });
return;
}
for (var p in prefs) {
if (prefArray[prefs[p].num]) {
if (prefName == p) {
versi += intValue + "-";
jQuery.cookie(p, null);
} else {
if (wiktGetPrefCookie(p) == 'true') {
versi += "1" + "-";
} else {
versi += "0" + "-";
}
jQuery.cookie(p, null);
}
} else {
versi += "0" + "-";
}
}
// Log choices to http://toolserver.org/~enwikt/prefs_stats - please disable if you consider this a security concern.
if (wgPageName == "Wiktionary:Per-browser_preferences") {
document.body.appendChild(newNode('img', {src: 'http://toolserver.org/~enwikt/prefs_stats/?action=store&cookie=' + versi}));
}
jQuery.cookie('WiktPrefs', versi, { expires: 30 });
return;
}
function ActivateChosenPrefs() {
if (wiktGetPrefCookie('WiktionaryUseJSPreferences') == 'true') {
//Start by refreshing the cookies, deleting the old format cookies.
wiktSetPrefCookie('WiktionaryUseJSPreferences', 'true');
for (var p in prefs) {
var pref = prefs[p];
if (wiktGetPrefCookie(p) == 'true') {
if ('isdisabled' in pref && pref.isdisabled())
continue;
if ("css" in pref) {
for (var c in pref.css) {
var css = pref.css[c];
mw.util.addCSS(css.selector + '{' + css.declarations + '}');
}
}
if ("js" in pref) {
for (var j in pref.js) {
var js = pref.js[j];
var ok = true;
if ('condition' in js) {
ok = false;
if(typeof js.condition == typeof function(){}) {
ok = js.condition();
} else if ('othercookie' in js.condition && 'comp' in js.condition && 'value' in js.condition) {
var oc = wiktGetPrefCookie(js.condition.othercookie);
if (js.condition.comp == '!=' && oc != js.condition.value)
ok = true;
}
}
if (ok) importScript(js.page, js.wiki, js.rev);
}
}
}
}
}
}
// TODO should not be global
enWiktPrefCheckboxs = [];
/* </pre>
== wiktAddCheckbox ==
<pre> */
// generate checkboxs
function wiktAddCheckbox(cookieToToggle, speedTip, isDisabled) {
var checkbox = document.createElement("input");
checkbox.type = 'checkbox';
checkbox.name = cookieToToggle;
checkbox.id = 'wikt_pref_chk_' + cookieToToggle;
checkbox.onclick = function() {
if (wiktGetPrefCookie(this.name) != 'true') {
wiktSetPrefCookie(this.name, 'true');
} else {
wiktSetPrefCookie(this.name, 'false');
}
};
checkbox.disabled = isDisabled;
if ('true' == wiktGetPrefCookie(cookieToToggle)) {
checkbox.checked = true;
}
var isPreferencePage = document.getElementById('isPreferencePage');
isPreferencePage.appendChild(checkbox);
if ('true' == wiktGetPrefCookie(cookieToToggle)) {
checkbox.checked = true;
}
var checkboxLabel = document.createElement('label');
checkboxLabel.setAttribute('for', checkbox.id);
checkboxLabel.appendChild(document.createTextNode(speedTip));
isPreferencePage.appendChild(checkboxLabel);
isPreferencePage.appendChild(document.createElement('br'));
return checkbox;
}
function wiktAddSeparator(wiktSepText) {
var pnod = document.createElement('p');
var isPreferencePage = document.getElementById('isPreferencePage');
pnod.appendChild(document.createTextNode(wiktSepText));
pnod.appendChild(document.createElement('hr'));
isPreferencePage.appendChild(pnod);
return pnod;
}
//not used just yet
function wiktAddTextBox(cookieToInput, speedTip) {
var textbox = document.createElement("input");
textbox.type = 'text';
textbox.width = 10;
textbox.name = cookieToInput;
textbox.onchange = function() {
wiktSetPrefCookie(this.name, this.value);
};
textbox.value = wiktGetPrefCookie(cookieToInput);
isPreferencePage.appendChild(textbox);
var text = document.createTextNode(speedTip);
isPreferencePage.appendChild(text);
return textbox;
}
/* </pre>
== CustomizePreferencesPage==
*Note that this needs to be re-written as a separate tab (or two or three) that appear when wgPageName=="Special:Preferences".
<pre> */
function CustomizePreferencesPage() {
//If on [[Special:Preferences]], add reminder link
if (wgCanonicalSpecialPageName === 'Keutamaan') {
var wiktlink = document.createElement("a");
wiktlink.setAttribute('href', '/wiki/Wiktionary:Keutamaan setiap pelayar');
var wiktltxt = document.createTextNode("Lihat juga: Keutamaan spesifik Wiktionary");
wiktlink.appendChild(wiktltxt);
document.getElementById('preferences').appendChild(wiktlink);
}
var isPreferencePage = document.getElementById('isPreferencePage');
if (!isPreferencePage) return;
//OK, so now we know we are on
//the Set EnglishWiktionary-specific Preferences page (or impersonation thereof)
// Hide the "noscript" div and display the "hasscript" one
var noscript = document.getElementById('wtprefs.noscript');
var hasscript = document.getElementById('wtprefs.hasscript');
if (noscript !== null && hasscript !== null) {
noscript.style.display = 'none';
hasscript.style.display = 'block';
}
// http://tools.wikimedia.de/~cmackenzie/make_checkboxs.html
// crop image to 21 pixels vertical, whatever horizontal.
var everyone = [
{ type: "checkbox", name: 'WiktionaryUseJSPreferences' },
{ type: "separator", text: '>PENTING - Jika kotak di atas tidak ditandakan, SEGALANYA di halaman ini dimatikan' },
{ type: "separator", text: 'Keutamaan yang menukar paparan antara muka.' },
// Hide special characters for edit field
{ type: "checkbox", name: 'WiktionaryPreferencesEditTools' },
// Allow special characters in [Search] input
{ type: "checkbox", name: 'WiktionaryPreferencesKeyPad' },
{ type: "checkbox", name: 'WiktionaryPreferencesHideSiteNotice' },
{ type: "checkbox", name: 'WiktHideLogo' },
// Andrew's clock
{ type: "checkbox",
name: 'WiktionaryPreferencesTime',
suboptions: [ "WiktionaryPreferencesTimeUTC", "WiktionaryPreferencesTickClock" ] },
{ type: "externcheckbox",
name: 'WiktionaryPreferencesTimeUTC',
text: 'Tukar jam untuk memaparkan UTC, bukan waktu tempatan.',
isdisabled: function() { return wiktGetPrefCookie('WiktionaryPreferencesTime') != 'true'; } },
// User:Connel MacKenzie/clock.js / wiktGetPrefCookie()
{ type: "externcheckbox",
name: 'WiktionaryPreferencesTickClock',
text: 'Tukar masa untuk mengemas kini setiap saat, bukannya setiap kali memuat semula halaman.',
isdisabled: function() { return wiktGetPrefCookie('WiktionaryPreferencesTime') != 'true'; } },
// User:Connel MacKenzie/clock.js / wiktGetPrefCookie()
{ type: "checkbox", name: 'WiktIrc2' },
{ type: "checkbox", name: 'WiktionaryPreferencesSmallRC' },
{ type: "checkbox", name: 'WiktSidebarTranslation' },
{ type: "checkbox", name: 'WiktFloatNavToggleLeft' },
{ type: "checkbox", name: 'WiktPreviewRightTOCs' },
{ type: "checkbox", name: 'WiktHideCopyrightWarning' },
{ type: "checkbox", name: 'WiktLogoTiles' },
{ type: "checkbox", name: 'WiktCustomTopToolbar' },
{ type: "separator", text: 'Keutamaan yang menukar paparan lema. [Hanya boleh berfungsi dengan kulit Monobook]' },
{ type: "checkbox", name: 'WiktionaryPreferencesHideLinesBetweenLanguages' },
{ type: "checkbox", name: 'WiktionaryPreferencesHideQualifierParens' },
{ type: "checkbox", name: 'WiktionaryPreferencesItalicParens' },
{ type: "checkbox", name: 'WiktHideAllParens' },
//{ type: "checkbox", name: 'WiktionaryPreferencesHideTransitivity' }, //doesn't work
{ type: "checkbox", name: 'WiktionaryPreferencesHideSister' },
{ type: "checkbox", name: 'WiktionaryPreferencesHideRankings' },
//there’s a typo somewhere here, but I’m not seeing it…
//See [[MediaWiki:Monobook.js#Dynamic Navigation Bars (experimental)]]
{ type: "externcheckbox",
name: 'WiktionaryPreferencesShowNav',
text: 'Show the translation sections expanded, instead of having them collapsed.' },
// MediaWiki:Monobook.js / getCookie
{ type: "checkbox", name: 'WiktionaryPreferencesHideTranslations' },
{ type: "checkbox", name: 'WiktionaryPreferencesBoxedInflections' },
{ type: "checkbox", name: 'WiktionaryPreferencesIndentSeeAlso' },
{ type: "checkbox", name: 'WiktFormOfPlain' },
{ type: "checkbox", name: 'WiktFormOfItalicQualifier' },
{ type: "checkbox", name: 'WiktFormOfItalicLemma' },
{ type: "checkbox", name: 'WiktFormOfItalicQualifierBoldLemma' },
{ type: "checkbox", name: 'WiktLatnMentionBold' },
{ type: "checkbox", name: 'WiktMentionGlossSingleQuotes' },
{ type: "checkbox", name: 'WiktHideTrGlossParens' },
{ type: "checkbox", name: 'WiktHideGlossParens' },
{ type: "checkbox", name: 'WiktPlainTransliterations' },
{ type: "checkbox", name: 'WiktRoundBullets4Lists' },
{ type: "checkbox", name: 'WiktMobile' },
{ type: "checkbox", name: 'WiktBCAD' },
{ type: "checkbox", name: 'WiktHeadersInline' },
{ type: "checkbox", name: 'WiktMoveWasWotdUp' },
{ type: "separator", text: 'Keutamaan berkaitan dengan pelayaran dan penyuntingan.' },
{ type: "externcheckbox",
name: 'WiktionaryDisableAutoRedirect',
text: 'Matikan javascript lencongan antara halaman yang berbeza hanya dalam kes.' },
// MediaWiki:Common.js / getCookie()
// [[User:Lupin/popups.js]]
{ type: "checkbox", name: 'WiktionaryPreferencesPopUps' },
{ type: "checkbox", name: 'WiktPrefConnelReformat' },
{ type: "checkbox", name: 'WiktAllowDoubleClickLookup' },
{ type: "checkbox", name: 'WiktAddProminentInterwikis' },
{ type: "checkbox", name: 'WiktAccelerateFormCreation' },
{ type: "checkbox", name: 'WiktAssistedEditing' },
{ type: "checkbox", name: 'WiktAjaxTransLinks' },
{ type: "checkbox", name: 'WiktMakeRedLinksBlack' },
{ type: "separator", text: 'Eksperimen - ini berkemungkinan menjadi rosak dan tidak boleh berfungsi di pelayar yang umum.' },
{ type: "checkbox", name: 'WiktAddStructure' },
{ type: "checkbox", name: 'WiktFilterContributions' },
{ type: "checkbox",
name: 'WiktNearbyPages',
suboptions: [
"WiktNearbyPagesLangHeadings",
"WiktNearbyPagesNavbar",
"WiktNearbyAlwaysLTR"
] },
{ type: "externcheckbox",
name: 'WiktNearbyPagesNavbar',
text: 'Tambah pautan di bar navigasi.',
isdisabled: function() { return wiktGetPrefCookie('WiktNearbyPages') != 'true'; } },
// User:Hippietrail/nearbypages.js / getCookie()
// TODO disable LTR checkbox when nearby headings is off
{ type: "externcheckbox",
name: 'WiktNearbyPagesLangHeadings',
text: 'Tambah pautan di bawah tajuk bahasa.',
isdisabled: function() { return wiktGetPrefCookie('WiktNearbyPages') != 'true'; } },
// User:Hippietrail/nearbypages.js / getCookie()
// TODO only enable this when nearyby headings is also enabled
{ type: "externcheckbox",
name: 'WiktNearbyAlwaysLTR',
text: 'Membuat pautan dari kiri ke kanan untuk semua bahasa.',
isdisabled: function() { return wiktGetPrefCookie('WiktNearbyPages') != 'true'; } },
// User:Hippietrail/nearbypages.js / getCookie()
{ type: "checkbox", name: 'WiktPerLanguage' },
{ type: "checkbox", name: 'WiktEtylAlwaysLink' },
{ type: "checkbox", name: 'WiktIPAConversion' },
{ type: "checkbox", name: 'WiktSideTabbedLanguages' },
{ type: "checkbox", name: 'WiktUsexEditor' },
{ type: "checkbox", name: 'WiktWSEdit' },
{ type: "checkbox", name: 'WiktDefEditOptions2' },
{ type: "checkbox", name: 'WiktLangNameISOCodeConverter' },
{ type: "checkbox", name: 'WiktRMTbotEntries' },
{ type: "checkbox", name: 'WiktEditSectionWTEDIT' },
{ type: "checkbox", name: 'WiktOrangeLinks' },
{ type: "checkbox", name: 'WiktInterwikiWatchlists' },
{ type: "checkbox", name: 'WiktInterwikiWatchlists2' },
{ type: "checkbox", name: 'WiktWatchlistNotifications' },
{ type: "checkbox", name: 'WiktRTRC' },
{ type: "checkbox", name: 'WiktWikilook' },
{ type: "checkbox", name: 'WiktFastBrowse' },
{ type: "checkbox", name: 'WiktSearchKeyboard' },
{ type: "checkbox", name: 'WiktXTE' },
];
var sysops = [
{ type: "separator", text: 'Sysop-only functions: ' },
{ type: "checkbox", name: 'WiktPrefDelCmnt' },
{ type: "externcheckbox",
name: 'WiktPrefVOA',
text: 'Use the Uber-Popups from VOA – WARNING – DANGEROUS',
isdisabled: function() { return true; } },
// Can't find where this is or was used
{ type: "checkbox", name: 'WiktCIDRRangeContribs' },
{ type: "checkbox", name: 'WiktBlockedNotice' },
{ type: "checkbox", name: 'WiktBeerParlourArchiver' }
];
function masterOnclick() {
var t = wiktGetPrefCookie('WiktionaryUseJSPreferences');
wiktSetPrefCookie('WiktionaryUseJSPreferences', t == 'true' ? 'false' : 'true');
updateGUI();
}
function groupOnclick(ev) {
var ele = window.event ? window.event.srcElement : ev.target;
var masterPref = ele.name;
var t = wiktGetPrefCookie(masterPref);
wiktSetPrefCookie(masterPref, t == 'true' ? 'false' : 'true');
updateGUIGroup(masterPref);
}
function getGUIItemFromPrefName(prefName) {
var lists = getGuiLists();
for (var l in lists) {
var list = lists[l];
for (var i in list) {
var item = list[i];
if ("name" in item && item.name == prefName)
return item;
}
}
return undefined;
}
function updateGUIGroup(masterPrefName) {
var masterPref = prefs[masterPrefName];
var masterDisable = !masterPref.ele.checked;
var master = getGUIItemFromPrefName(masterPrefName);
var subPrefs = master.suboptions;
for (var sp in subPrefs) {
var subPrefName = subPrefs[sp];
var item = getGUIItemFromPrefName(subPrefName);
var isdisabled = masterDisable;
switch (item.type) {
case "checkbox":
if (typeof pref.isdisabled !== "undefined")
isdisabled |= pref.isdisabled();
pref.ele.disabled = isdisabled;
break;
case "externcheckbox":
if (typeof item.isdisabled !== "undefined")
isdisabled |= item.isdisabled();
item.ele.disabled = isdisabled;
break;
}
}
}
function buildGUI() {
var masterDisable = false;
var lists = getGuiLists();
for (var l in lists) {
var list = lists[l];
for (var i in list) {
var item = list[i];
var pref = prefs[item.name];
var isdisabled = masterDisable;
switch (item.type) {
case "checkbox":
if (typeof pref.isdisabled !== "undefined")
isdisabled |= pref.isdisabled();
pref.ele = item.ele = wiktAddCheckbox(item.name, pref.text, isdisabled);
if (l == 0 && i == 0) {
masterDisable = !pref.ele.checked;
pref.ele.onclick = masterOnclick;
}
else if ("suboptions" in item) {
pref.ele.onclick = groupOnclick;
}
break;
case "separator":
item.ele = wiktAddSeparator(item.text);
break;
case "externcheckbox":
if (typeof item.isdisabled !== "undefined")
isdisabled |= item.isdisabled();
item.ele = wiktAddCheckbox(item.name, item.text, isdisabled);
}
}
}
}
function updateGUI() {
var masterDisable = false;
var lists = getGuiLists();
for (var l in lists) {
var list = lists[l];
for (var i in list) {
var item = list[i];
var pref = prefs[item.name];
var isdisabled = masterDisable;
switch (item.type) {
case "checkbox":
if (typeof pref.isdisabled !== "undefined")
isdisabled |= pref.isdisabled();
pref.ele.disabled = isdisabled;
if (l == 0 && i == 0)
masterDisable = !pref.ele.checked;
break;
case "externcheckbox":
if (typeof item.isdisabled !== "undefined")
isdisabled |= item.isdisabled();
item.ele.disabled = isdisabled;
}
}
}
}
// MSIE compatibility workaround for indexOf might not work
// on skins other than monobook
// If they have a delete checkbox on this page, they are a sysop.
function isSysop() {
if ("indexOf" in Array)
return wgUserGroups !== null && wgUserGroups.indexOf("sysop") != -1;
return document.getElementById('ca-delete') !== null;
}
function getGuiLists() {
var lists = [everyone];
if (isSysop())
lists.push(sysops);
return lists;
}
buildGUI();
}
function wiktCustomPrefsLoad() {
CustomizePreferencesPage();
ActivateChosenPrefs();
}
jQuery(document).ready(wiktCustomPrefsLoad);