Difference between revisions of "User:Podehaye/common.js"

From Wikibase Personal data
Jump to navigation Jump to search
Line 8: Line 8:
 
mw.loader.using( 'oojs-ui-core' ).done( function () {
 
mw.loader.using( 'oojs-ui-core' ).done( function () {
 
$( function () {
 
$( function () {
var input = new OO.ui.TextInputWidget( {
+
var name = new OO.ui.TextInputWidget( {
placeholder: 'This is an entry box'
+
placeholder: 'cookie name'
 
} );
 
} );
 
 
 
input.on( 'enter', function () {
 
input.on( 'enter', function () {
// Check for duplicates and prevent empty input
+
            mw.cookie.set( name.getValue(), 'unknown' );
if ( list.findItemFromData( input.getValue() ) ||
+
 
input.getValue() === '' ) {
+
        }
input.$element.addClass( 'todo-error' );
 
return;
 
}
 
 
 
 
} );
 
} );

Revision as of 00:34, 18 May 2019

mw.notify( $('<span>Welcome, Paul, your <a href="https://wiki.personaldata.io/wiki/User:Podehaye/common.js">user script</a> is loading!</span>') );

mw.loader.load( '//wiki.personaldata.io/w/index.php?title=User:Podehaye/button.js&action=raw&ctype=text/javascript' ); // front button for testing



// Button:
mw.loader.using( 'oojs-ui-core' ).done( function () {
$( function () {
	var name = new OO.ui.TextInputWidget( {
			placeholder: 'cookie name'
		} );
		
	input.on( 'enter', function () {
             mw.cookie.set( name.getValue(), 'unknown' );

        }
		
	} );

	// Append the app widgets
  $( '#mw-content-text' ).prepend(
		input.$element);

} );

} );