User:SPage (WMF)/JStransforms.js

// Insert text input to take //	https://en.wikipedia.org/w/api.php?action=query&list=geosearch&format=json&gscoord=37.786952%7C-122.399523&gsradius=10000&gslimit=10 // and turn it into // ( function ( $, mw ) {	if ( mw.config.get( 'wgTitle' ) !== 'SPage (WMF)/JS test') {		console.log( 'TEMP, not my JS_test, so returning');		return;	}   // TODO have a structure of changes to make and draw a radio button for each    var transforms = {        'make ApiEx' : function( str ) {            var res;             res = str.replace( /https?:/,  ).replace( /^\/\//, );            return res;        }    };    var $cpanel = $( '  ' ),        $inp;    $inp = $cpanel.find( '#inp' );    $inp.change(function { var res, transform = $('input[name="workJStransform"]:checked').val; alert( "Handler for .change called, radio function =" + transform ); res = transforms[transform]( $( this ).val ); $cpanel.find( '#result').html( res ); } );   // Create a radio button for each transform    $.each( transforms, function( key, value ) { var $element=$('' + key + ' '); $cpanel.append( $element ); } );   // Check the first radiobutton    $cpanel.find( '[name="workJStransform"]:first').prop( 'checked', true );    $cpanel.append( ' ' );    $ ( document ).ready( function { $( '#workArea' ).after(           $cpanel        ); }); window.console.log( 'mw.makeApiEx defined' ); } )( jQuery, mediaWiki );