User
Difference between revisions of "Seb35/bluell.js"
< User:Seb35
(simplification d’une requête SPARQL) |
(+proficiency) |
||
Line 5: | Line 5: | ||
'https://lingualibre.org/bigdata/namespace/wdq/sparql', | 'https://lingualibre.org/bigdata/namespace/wdq/sparql', | ||
{ | { | ||
− | query: 'SELECT DISTINCT ?user ?userLabel WHERE { ? | + | query: 'SELECT DISTINCT ?user ?userLabel WHERE { ?user prop:P2 entity:Q3 . ?user rdfs:label ?userLabel . FILTER( LANG(?userLabel) = "en" ) } ORDER BY ?userLabel' |
} | } | ||
).done( function( users ) { | ).done( function( users ) { | ||
Line 29: | Line 29: | ||
'https://lingualibre.org/bigdata/namespace/wdq/sparql', | 'https://lingualibre.org/bigdata/namespace/wdq/sparql', | ||
{ | { | ||
− | query: 'SELECT DISTINCT ?gender ?genderLabel WHERE { ? | + | query: 'SELECT DISTINCT ?gender ?genderLabel WHERE { ?gender prop:P2 entity:Q7 . ?gender rdfs:label ?genderLabel . FILTER( LANG(?genderLabel) = "en" ) } ORDER BY ?gender' |
} | } | ||
).done( function( genders ) { | ).done( function( genders ) { | ||
Line 53: | Line 53: | ||
'https://lingualibre.org/bigdata/namespace/wdq/sparql', | 'https://lingualibre.org/bigdata/namespace/wdq/sparql', | ||
{ | { | ||
− | query: 'SELECT DISTINCT ?language ?languageLabel WHERE { ? | + | query: 'SELECT DISTINCT ?language ?languageLabel WHERE { ?language prop:P2 entity:Q4 . ?language rdfs:label ?languageLabel . FILTER( LANG(?languageLabel) = "en" ) } ORDER BY ?languageLabel' |
} | } | ||
).done( function( languages ) { | ).done( function( languages ) { | ||
Line 69: | Line 69: | ||
$( '#filterlanguage' ).append( | $( '#filterlanguage' ).append( | ||
+ | dropdown.$element | ||
+ | ); | ||
+ | |||
+ | } ); | ||
+ | |||
+ | $.getJSON( | ||
+ | 'https://lingualibre.org/bigdata/namespace/wdq/sparql', | ||
+ | { | ||
+ | query: 'SELECT DISTINCT ?language ?languageLabel WHERE { ?record prop:P2 entity:Q2 . ?record prop:P4 ?language . OPTIONAL { ?language rdfs:label ?languageLabel . FILTER( LANG(?languageLabel) = "en" ) } }' | ||
+ | } | ||
+ | ).done( function( proficiencies ) { | ||
+ | console.log( proficiencies ); | ||
+ | var dropdown = new OO.ui.DropdownWidget( { | ||
+ | menu: { | ||
+ | items: proficiencies.results.bindings.map( function( x ) { | ||
+ | return new OO.ui.MenuOptionWidget( { | ||
+ | data: x.proficiency.value.substr( 31 ), | ||
+ | label: x.proficiencyLabel.value | ||
+ | } ); | ||
+ | } ) | ||
+ | } | ||
+ | } ); | ||
+ | |||
+ | $( '#filterlevelofproficiency' ).append( | ||
dropdown.$element | dropdown.$element | ||
); | ); |
Revision as of 14:31, 29 July 2021
$( function (){
mw.loader.using( ['oojs', 'oojs-ui'], function () {
$.getJSON(
'https://lingualibre.org/bigdata/namespace/wdq/sparql',
{
query: 'SELECT DISTINCT ?user ?userLabel WHERE { ?user prop:P2 entity:Q3 . ?user rdfs:label ?userLabel . FILTER( LANG(?userLabel) = "en" ) } ORDER BY ?userLabel'
}
).done( function( users ) {
console.log( users );
var dropdown = new OO.ui.DropdownWidget( {
menu: {
items: users.results.bindings.map( function( x ) {
return new OO.ui.MenuOptionWidget( {
data: x.user.value.substr( 31 ),
label: x.userLabel.value
} );
} )
}
} );
$( '#filteruser' ).append(
dropdown.$element
);
} );
$.getJSON(
'https://lingualibre.org/bigdata/namespace/wdq/sparql',
{
query: 'SELECT DISTINCT ?gender ?genderLabel WHERE { ?gender prop:P2 entity:Q7 . ?gender rdfs:label ?genderLabel . FILTER( LANG(?genderLabel) = "en" ) } ORDER BY ?gender'
}
).done( function( genders ) {
console.log( genders );
var dropdown = new OO.ui.DropdownWidget( {
menu: {
items: genders.results.bindings.map( function( x ) {
return new OO.ui.MenuOptionWidget( {
data: x.gender.value.substr( 31 ),
label: x.genderLabel.value
} );
} )
}
} );
$( '#filtergender' ).append(
dropdown.$element
);
} );
$.getJSON(
'https://lingualibre.org/bigdata/namespace/wdq/sparql',
{
query: 'SELECT DISTINCT ?language ?languageLabel WHERE { ?language prop:P2 entity:Q4 . ?language rdfs:label ?languageLabel . FILTER( LANG(?languageLabel) = "en" ) } ORDER BY ?languageLabel'
}
).done( function( languages ) {
console.log( languages );
var dropdown = new OO.ui.DropdownWidget( {
menu: {
items: languages.results.bindings.map( function( x ) {
return new OO.ui.MenuOptionWidget( {
data: x.language.value.substr( 31 ),
label: x.languageLabel.value
} );
} )
}
} );
$( '#filterlanguage' ).append(
dropdown.$element
);
} );
$.getJSON(
'https://lingualibre.org/bigdata/namespace/wdq/sparql',
{
query: 'SELECT DISTINCT ?language ?languageLabel WHERE { ?record prop:P2 entity:Q2 . ?record prop:P4 ?language . OPTIONAL { ?language rdfs:label ?languageLabel . FILTER( LANG(?languageLabel) = "en" ) } }'
}
).done( function( proficiencies ) {
console.log( proficiencies );
var dropdown = new OO.ui.DropdownWidget( {
menu: {
items: proficiencies.results.bindings.map( function( x ) {
return new OO.ui.MenuOptionWidget( {
data: x.proficiency.value.substr( 31 ),
label: x.proficiencyLabel.value
} );
} )
}
} );
$( '#filterlevelofproficiency' ).append(
dropdown.$element
);
} );
} );
} );
/*
lang = mw.config.get( 'wgUserLanguage' );
AudioBox.prototype.display = function() {
this.$node.find( '.ab-title' ).text( "un label" + lang ); //this.label
this.$node.find( '.ab-metadata' ).text( this.lang + ' - ' + this.speaker );
this.audioNode.src = this.media;
this.$node.find( '.ab-playbutton' ).click( this.audioNode.play.bind( this.audioNode ) );
}
function createAudioBoxes( data ) {
if ( data.query === undefined || data.query.rwrecords === undefined || data.query.rwrecords.length < 2 ) {
displayError( 'nodata' );
return;
}
ab1 = new AudioBox( data.query.rwrecords[ 0 ], $( '.audiobox' ).eq( 0 ) );
ab2 = new AudioBox( data.query.rwrecords[ 1 ], $( '.audiobox' ).eq( 1 ) );
}
function getRecords() {
var api = new mw.Api();
api.get( {
action: 'query',
format: 'json',
list: 'rwrecords',
rwrlimit: '2',
rwrsort: 'pageid',
rwrdir: 'descending',
rwrformat: 'qid'
} ).then( createAudioBoxes, displayError );
}
function displayError( code, error ) {
console.warn( code, error );
}
if ( mw.config.get( 'wgPageName' ) === 'User:Nicolas_NALLET' ) {
mw.loader.using( [ 'mediawiki.api', 'ext.recordWizard.wikibase' ] ).then( getRecords );
$('.selectors').append(lang.$element);
$('.selectors').append(list.$element);
}
*/