MediaWiki
Difference between revisions of "LexemeQueriesGenerator.js"
Line 10: | Line 10: | ||
new OO.ui.MenuOptionWidget({ data: 'Q34', label: 'mar - Marathi' }), | new OO.ui.MenuOptionWidget({ data: 'Q34', label: 'mar - Marathi' }), | ||
new OO.ui.MenuOptionWidget({ data: 'Q209', label: 'bre - Breton' }) | 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 = [ | posArray = [ | ||
Line 29: | Line 34: | ||
], | ], | ||
endpointsArray = [ | endpointsArray = [ | ||
− | new OO.ui.RadioOptionWidget({ data: 'wikidata', label: 'Wikidata' }), | + | new OO.ui.RadioOptionWidget({ data: 'wikidata', label: 'Wikidata', selected: true }), |
new OO.ui.RadioOptionWidget({ data: 'Dbnary', label: 'Dbnary' }), | new OO.ui.RadioOptionWidget({ data: 'Dbnary', label: 'Dbnary' }), | ||
//new OO.ui.RadioOptionWidget({ data: 'LinguaLibre', label: 'LinguaLibre' }), | //new OO.ui.RadioOptionWidget({ data: 'LinguaLibre', label: 'LinguaLibre' }), | ||
Line 35: | Line 40: | ||
// Elements | // Elements | ||
− | var lemma = | + | var lemma = new OO.ui.TextInputWidget({ |
− | + | id: 'lqg-lemma', | |
− | + | placeholder: 'book', | |
− | + | value: 'book', | |
− | languages = new OO.ui.DropdownWidget( { | + | label: 'Word', |
+ | icon: 'search' | ||
+ | }), | ||
+ | languages = new OO.ui.DropdownWidget({ | ||
+ | id: 'lqg-languages', | ||
label: 'Source languages', | label: 'Source languages', | ||
menu: { items: languagesArray1 } | menu: { items: languagesArray1 } | ||
− | } ), | + | }), |
+ | languagesB = new OO.ui.ComboBoxInputWidget({ | ||
+ | // value: 'Q34', | ||
+ | options: languagesArrayB, | ||
+ | id: 'lqg-languages', | ||
+ | placeholder : 'Source languages', | ||
+ | }), | ||
pos = new OO.ui.DropdownWidget( { | pos = new OO.ui.DropdownWidget( { | ||
+ | id: 'lqg-pos', | ||
label: 'Part-of-speech', | label: 'Part-of-speech', | ||
menu: { items: posArray } | menu: { items: posArray } | ||
− | } ), | + | }), |
− | infoTypes = new OO.ui.DropdownWidget( { | + | infoTypes = new OO.ui.DropdownWidget({ |
+ | id: 'lqg-infoTypes', | ||
label: 'Information to fetch if any', | label: 'Information to fetch if any', | ||
menu: { items: infoTypesArray } | menu: { items: infoTypesArray } | ||
− | } ), | + | }), |
− | translations = new OO.ui.DropdownWidget( { | + | translations = new OO.ui.DropdownWidget({ |
+ | id: 'lqg-translations', | ||
label: 'Translations', | label: 'Translations', | ||
menu: { items: languagesArray2 } | menu: { items: languagesArray2 } | ||
− | } ), | + | }), |
− | enpoints = new OO.ui.RadioSelectWidget( { | + | enpoints = new OO.ui.RadioSelectWidget({ |
+ | id: 'lqg-endpoints', | ||
label: 'Radios buttons', | label: 'Radios buttons', | ||
+ | |||
items: endpointsArray | items: endpointsArray | ||
} ), | } ), | ||
− | generate = new OO.ui.ButtonWidget( { label: 'Generate' } ), | + | generate = new OO.ui.ButtonWidget({ id: 'lqg-generate', label: 'Generate' } ), |
− | limit = new OO.ui.CheckboxInputWidget( { selected: true } ), | + | 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( { | queryDisplay = new OO.ui.MultilineTextInputWidget( { | ||
+ | id: 'lqg-pos', | ||
value: `Query will appear here.\n\n\n\n\n\n`, | value: `Query will appear here.\n\n\n\n\n\n`, | ||
multiline: true, | multiline: true, | ||
Line 67: | Line 95: | ||
minRows: 10, | minRows: 10, | ||
maxRows: 20 | maxRows: 20 | ||
− | } | + | } ); |
− | |||
− | |||
− | |||
Line 79: | Line 104: | ||
} ); | } ); | ||
− | + | ||
fieldset.addItems( [ | 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 ); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 20:28, 14 December 2021
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 );