Difference between revisions of "User:Podehaye/common.js"
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 key = new OO.ui.TextInputWidget( { | |
| − | var | + | placeholder: 'key' |
| − | placeholder: ' | ||
} ), | } ), | ||
| + | value = new OO.ui.TextInputWidget( { | ||
| + | placeholder: 'value' | ||
| + | } ), | ||
| + | button = new OO.ui.ButtonWidget( | ||
| + | label: 'save' | ||
| + | } ), | ||
info = new OO.ui.LabelWidget( { | info = new OO.ui.LabelWidget( { | ||
| − | label: ' | + | label: 'label' |
| − | |||
} ); | } ); | ||
| − | |||
| − | + | button.on( 'enter', function () { | |
| − | mw. | + | mw.storage.set( key.getValue(), value.getValue() ); |
| − | |||
}); | }); | ||
| Line 27: | Line 29: | ||
// Append the app widgets | // Append the app widgets | ||
$( '#mw-content-text' ).prepend( | $( '#mw-content-text' ).prepend( | ||
| − | + | key.$element, | |
| − | + | value.$element, | |
| − | + | button.$element, | |
| − | info.$element | + | info.$element |
); | ); | ||
Revision as of 00:52, 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 key = new OO.ui.TextInputWidget( {
placeholder: 'key'
} ),
value = new OO.ui.TextInputWidget( {
placeholder: 'value'
} ),
button = new OO.ui.ButtonWidget(
label: 'save'
} ),
info = new OO.ui.LabelWidget( {
label: 'label'
} );
button.on( 'enter', function () {
mw.storage.set( key.getValue(), value.getValue() );
});
// Append the app widgets
$( '#mw-content-text' ).prepend(
key.$element,
value.$element,
button.$element,
info.$element
);
} );
} );