|
|
(34 intermediate revisions by 2 users not shown) |
Line 1: |
Line 1: |
− | /* Fix links to WIkipedia on P19 property*/
| |
− | $('div#P19 .wb-external-id').attr('href', $( 'div#P19 .wb-external-id' ).attr('href').replace(/\+/g, "_"));
| |
| | | |
− | /*OOui Tuto*/
| |
− |
| |
− | $( function () {
| |
− | var input = new OO.ui.TextInputWidget(),
| |
− | list = new OO.ui.SelectWidget();
| |
− |
| |
− | // Append to the wrapper
| |
− | $( '.wrapper' ).append(
| |
− | input.$element,
| |
− | list.$element
| |
− | );
| |
− | } );
| |
− |
| |
− | /*Display a drilldown interface for record*/
| |
− | list = new OO.ui.SelectWidget();
| |
− | var lang = new OO.ui.DropdownWidget( {
| |
− | label: 'Select a language',
| |
− | menu: {
| |
− | items: [
| |
− | new OO.ui.MenuOptionWidget( {
| |
− | data: 'French'
| |
− | } ),
| |
− | new OO.ui.MenuOptionWidget( {
| |
− | data: 'b',
| |
− | label: 'Second',
| |
− | indicator: 'clear'
| |
− | } ),
| |
− | new OO.ui.MenuOptionWidget( {
| |
− | data: 'c',
| |
− | label: 'Third'
| |
− | } ),
| |
− | new OO.ui.MenuOptionWidget( {
| |
− | data: 'c',
| |
− | label: 'The fourth option has an overly long label'
| |
− | } ),
| |
− | new OO.ui.MenuOptionWidget( {
| |
− | icon: 'feedback',
| |
− | data: 'd',
| |
− | label: 'The fifth option has an icon'
| |
− | } )
| |
− | ]
| |
− | }
| |
− | } );
| |
− |
| |
− | //lang = new OO.ui.DropdownWidget();
| |
− |
| |
− |
| |
− |
| |
− |
| |
− | AudioBox.prototype.display = function() {
| |
− | this.$node.find( '.ab-title' ).text( 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);
| |
− | }
| |