MediaWiki
LexemeQueriesGenerator.js
Note: 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.
console.log("User:Yug/MediaWiki:OOUI.js script loaded/ran");
// Toolbox
var runQuery = function(){
return 'https://query.wikidata.org/#';
}
// Data
var languagesArray1 = [
new OO.ui.MenuOptionWidget({ data: 'Q113', label: 'cmn - Mandarin Chinese' }),
new OO.ui.MenuOptionWidget({ data: 'Q34', label: 'mar - Marathi' }),
new OO.ui.MenuOptionWidget({ data: 'Q209', label: 'bre - Breton' })
],
languagesArrayB = [
{ data: 'Q113', label: 'cmn - Mandarin Chinese' },
{ data: 'Q34', label: 'mar - Marathi' },
{ data: 'Q209', label: 'bre - Breton' }
],
posArray = [
new OO.ui.MenuOptionWidget({ data: 'Q24905', label: 'verb' }),
new OO.ui.MenuOptionWidget({ data: 'Q34698', label: 'adjective' }),
new OO.ui.MenuOptionWidget({ data: 'Q380057', label: 'adverb' }),
new OO.ui.MenuOptionWidget({ data: 'Q1084', label: 'noun' })
],
infoTypesArray = [
new OO.ui.MenuOptionWidget({ data: '1', label: 'Just look !' }),
new OO.ui.MenuOptionWidget({ data: '2', label: 'Sense' }),
new OO.ui.MenuOptionWidget({ data: '3', label: 'Sense, definition' }),
new OO.ui.MenuOptionWidget({ data: '4', label: 'Sense, definition and examples'}),
],
languagesArray2 = [
new OO.ui.MenuOptionWidget({ data: 'Q113', label: 'cmn - Mandarin Chinese' }),
new OO.ui.MenuOptionWidget({ data: 'Q34', label: 'mar - Marathi' }),
new OO.ui.MenuOptionWidget({ data: 'Q209', label: 'bre - Breton' })
],
endpointsArray = [
new OO.ui.RadioOptionWidget({ data: 'wikidata', label: 'Wikidata', selected: true }),
new OO.ui.RadioOptionWidget({ data: 'Dbnary', label: 'Dbnary' }),
//new OO.ui.RadioOptionWidget({ data: 'LinguaLibre', label: 'LinguaLibre' }),
];
// Elements
var lemma = new OO.ui.TextInputWidget({
id: 'lqg-lemma',
placeholder: 'book',
value: 'book',
label: 'Word',
icon: 'search'
}),
languages = new OO.ui.DropdownWidget({
id: 'lqg-languages',
label: 'Source languages',
menu: { items: languagesArray1 }
}),
languagesB = new OO.ui.ComboBoxInputWidget({
// value: 'Q34',
options: languagesArrayB,
id: 'lqg-languages',
placeholder : 'Source languages',
}),
pos = new OO.ui.DropdownWidget( {
id: 'lqg-pos',
label: 'Part-of-speech',
menu: { items: posArray }
}),
infoTypes = new OO.ui.DropdownWidget({
id: 'lqg-infoTypes',
label: 'Information to fetch if any',
menu: { items: infoTypesArray }
}),
translations = new OO.ui.DropdownWidget({
id: 'lqg-translations',
label: 'Translations',
menu: { items: languagesArray2 }
}),
enpoints = new OO.ui.RadioSelectWidget({
id: 'lqg-endpoints',
label: 'Radios buttons',
items: endpointsArray
} ),
generate = new OO.ui.ButtonWidget({ id: 'lqg-generate', label: 'Generate' } ),
run = new OO.ui.ButtonWidget({
id: 'lqg-pos',
label:'Run !',
href:runQuery(),
target:'new'
}),
limit = new OO.ui.CheckboxInputWidget({ id: 'lqg-limit', selected: true, }),
limitLabel = new OO.ui.LabelWidget( { label: 'Limit to 100 (faster)' }),
queryDisplay = new OO.ui.MultilineTextInputWidget( {
id: 'lqg-pos',
value: `Query will appear here.\n\n\n\n\n\n`,
multiline: true,
autosize: true,
minRows: 10,
maxRows: 20
} );
// An example of a fieldset with horizontal layout.
var fieldset = new OO.ui.FieldsetLayout( {
label: 'Queries Generator for Wikidata Lexemes'
} );
fieldset.addItems( [
new OO.ui.FieldLayout(
new OO.ui.Widget( {
content: [
new OO.ui.HorizontalLayout( { items: [
lemma,
pos,
languages,
]}),
new OO.ui.HorizontalLayout( { items: [
languagesB,
infoTypes,
translations
]}),
new OO.ui.HorizontalLayout( { items: [
generate,
run,
limit,
limitLabel,
enpoints,
]}),
queryDisplay
]
}))
]
);
// Add an horizontal field layout
$( "#lqg" ).append( fieldset.$element );