MediaWiki
Gadget-sandbox.js
From Dogcraft Wiki
m (calling oouiconfirm directly - doubt this will work) |
(doubt this will work even less) |
||
Line 6: | Line 6: | ||
function confirmDialoge() { | function confirmDialoge() { | ||
return (OO.ui.confirm( 'Are you sure?' ).done( function ( confirmed ) { | return (OO.ui.confirm( 'Are you sure?' ).done( function ( confirmed ) { | ||
if ( confirmed ) { | if ( confirmed ) { | ||
console.log( 'User clicked "OK"!' ); | console.log( 'User clicked "OK"!' ); | ||
Line 17: | Line 16: | ||
})); | })); | ||
} | } | ||
function inviteClicked(callback) { | |||
if (callback) { | |||
return true; | |||
} else { | |||
return false; | |||
} | |||
return -1; | |||
} | |||
$( function () { | $( function () { | ||
Line 38: | Line 46: | ||
$( '#mw-content-text' ).append( button.$element ); | $( '#mw-content-text' ).append( button.$element ); | ||
$( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('click', OO.ui.confirm( 'Are you sure?' ).done( function ( confirmed ) { | $( '.page-User_Domino_Sandbox a[href="https://discord.gg/r5xDRcy"]' ).on('click', inviteClicked(OO.ui.confirm( 'Are you sure?' ).done( function ( confirmed ) { | ||
if ( confirmed ) { | if ( confirmed ) { | ||
console.log( 'User clicked "OK"!' ); | console.log( 'User clicked "OK"!' ); | ||
Line 48: | Line 55: | ||
return false; | return false; | ||
} | } | ||
})); | }))); | ||
/*function (e) { | /*function (e) { | ||
e.preventDefault(); | e.preventDefault(); |
Revision as of 21:54, 2 December 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 confirmDialoge() {
return (OO.ui.confirm( 'Are you sure?' ).done( function ( confirmed ) {
if ( confirmed ) {
console.log( 'User clicked "OK"!' );
//window.location.href = e.target.href;
return true;
} else {
console.log( 'User clicked "Cancel" or closed the dialog.' );
return false;
}
}));
}
function inviteClicked(callback) {
if (callback) {
return true;
} else {
return false;
}
return -1;
}
$( 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', inviteClicked(OO.ui.confirm( 'Are you sure?' ).done( function ( confirmed ) {
if ( confirmed ) {
console.log( 'User clicked "OK"!' );
//window.location.href = e.target.href;
return true;
} else {
console.log( 'User clicked "Cancel" or closed the dialog.' );
return false;
}
})));
/*function (e) {
e.preventDefault();
console.log('1');
var result = confirmDialoge();
console.log('3');
return result;
});*/
});
});
}
});
This page was last modified on 2 December 2021, at 21:54. (2 years ago)