MediaWiki
Gadget-sandbox.js
From Dogcraft Wiki
(-) |
(-) |
||
Line 25: | Line 25: | ||
$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('click', function (e) { | $( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('click', function (e) { | ||
var | var target = e.href; | ||
e.preventDefault(); | |||
OO.ui.confirm( 'Are you sure?' ).done( function ( confirmed ) { | |||
if ( confirmed ) { | if ( confirmed ) { | ||
console.log( 'User clicked "OK"!' ); | console.log( 'User clicked "OK"!' ); | ||
window.location.href = target; | |||
return true; | return true; | ||
} else { | } else { | ||
Line 35: | Line 38: | ||
}); | }); | ||
console.log(conf); | console.log(conf); | ||
return conf; | |||
}); | }); | ||
Revision as of 23:55, 25 November 2021
$(document).ready(function() {
if (mw.config.get('wgPageName') === 'User:Domino/Sandbox') {
mw.loader.using( ['oojs-ui-core', 'oojs-ui-widgets', 'oojs-ui-windows'] ).done( function () {
$( function () {
var button = new OO.ui.ButtonWidget( {
label: 'Click me!',
classes: [ 'confirm-sandbox' ]
});
//button.on( 'click', function () {
//alert( 'You clicked the button!' );
/*OO.ui.alert( 'Something happened!' ).done( function () {
console.log( 'User closed the dialog.' );
});*/
/*OO.ui.confirm( 'Are you sure?' ).done( function ( confirmed ) {
if ( confirmed ) {
console.log( 'User clicked "OK"!' );
} else {
console.log( 'User clicked "Cancel" or closed the dialog.' );
}
});
});*/
$( '#mw-content-text' ).append( button.$element );
$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('click', function (e) {
var target = e.href;
e.preventDefault();
OO.ui.confirm( 'Are you sure?' ).done( function ( confirmed ) {
if ( confirmed ) {
console.log( 'User clicked "OK"!' );
window.location.href = target;
return true;
} else {
console.log( 'User clicked "Cancel" or closed the dialog.' );
return false;
}
});
console.log(conf);
return conf;
});
});
});
}
});
This page was last modified on 25 November 2021, at 23:55. (2 years ago)