User

Difference between revisions of "Seb35/bluell.js"

< User:Seb35

 
Line 2: Line 2:
 
mw.loader.using( ['oojs', 'oojs-ui'], function () {
 
mw.loader.using( ['oojs', 'oojs-ui'], function () {
  
var dropdown = new OO.ui.DropdownWidget( {
+
$.getJSON(
data: 'a',
+
'https://lingualibre.org/bigdata/namespace/wdq/sparql',
label: 'First'
+
{
} );  
+
query: 'SELECT DISTINCT ?user ?userLabel WHERE { ?record prop:P2 entity:Q2 . ?record prop:P5 ?user . OPTIONAL { ?user rdfs:label ?userLabel . FILTER( LANG(?userLabel) = "en" ) . } }'
 +
}
 +
).done( function( users ) {
 +
console.log( users );
 +
var dropdown = new OO.ui.DropdownWidget( {
 +
data: 'a',
 +
label: 'First'
 +
} );
  
$( '#filteruser' ).append(
+
$( '#filteruser' ).append(
 
dropdown.$element
 
dropdown.$element
);
+
);
  
} );
+
} );
  
 
} );
 
} );

Revision as of 08:42, 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 { ?record prop:P2 entity:Q2 . ?record prop:P5 ?user . OPTIONAL { ?user rdfs:label ?userLabel . FILTER( LANG(?userLabel) = "en" ) . } }'
		}
	).done( function( users ) {
		console.log( users );
		var dropdown = new OO.ui.DropdownWidget( {
					data: 'a',
					label: 'First'
		} );

		$( '#filteruser' ).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);
}
*/