User:A. Amritesh/common.js

// importScript('User:SSethi (WMF)/Sandbox/SimpleUserScriptExamples.js'); mw.loader.using( 'oojs-ui-widgets' ).done(function{ var buttonIcon = new OO.ui.ButtonWidget( { icon: 'upTriangle', title: 'Up', classes:[ 'my-button'] } );   $( '#mw-content-text' ).after(buttonIcon.$element ); // buttonIcon.setIcon( 'upTriangle' ); $('.my-button').css('float','right'); $('.my-button').css('padding','0.5em 0em'); buttonIcon.on('click', function{$(window).scrollTop(0);}); // .onClick(document.getElementById(firstHeading).focus({preventScroll:false})) }); mw.loader.using( 'oojs-ui-widgets' ).done(function{ var toggleSwitch = new OO.ui.PopupButtonWidget({ label: 'Dark Focus', classes:[ 'my-togglebtn'], popup: { $content: $( ' Reload to disable. ' ), padded: true, align: 'forwards' } });

$('#bodyContent').prepend( toggleSwitch.$element ); $('.my-togglebtn').css('float','right'); $('.my-togglebtn').css('padding','0.5em 0em'); toggleSwitch.on('click',function focus{	$('.my-togglebtn').css('background-color','black');	$('.my-togglebtn').css('color','white');	$("p").on({ mouseenter: function{ $(this).css("background-color", "black"); $(this).css("color", "white"); }, mouseleave: function{ $(this).css("background-color", "white"); $(this).css("color", "black"); }	});

$("pre,code,table").on({ mouseenter: function{    $(this).css("background-color", "black");    $(this).css("color", "white");  },  mouseleave: function{    $(this).css("background-color", "#f8f9fa");    $(this).css("color", "black");    }  }); } ); });

mw.loader.using( 'oojs-ui-widgets' ).done(function{	var colors = new OO.ui.PopupButtonWidget({ label: 'Colors', classes:[ 'my-color'], popup: { $content: $( '' ), padded: true, align: 'forwards' } }); $('#bodyContent').prepend( colors.$element ); $('.my-color').css('float','left');

colors.on('click',function rain{ var s = " "; $('.my-color').popup($content(s));  }); });

function rainbow(numOfSteps, step) { // This function generates vibrant, "evenly spaced" colours (i.e. no clustering). This is ideal for creating easily distinguishable vibrant markers in Google Maps and other apps. // Adam Cole, 2011-Sept-14 // HSV to RBG adapted from: http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript var r, g, b;   var h = step / numOfSteps; var i = (h * 6); var f = h * 6 - i;   var q = 1 - f;    switch(i % 6){ case 0: r = 1; g = f; b = 0; break; case 1: r = q; g = 1; b = 0; break; case 2: r = 0; g = 1; b = f; break; case 3: r = 0; g = q; b = 1; break; case 4: r = f; g = 0; b = 1; break; case 5: r = 1; g = 0; b = q; break; }   var c = "#" + ("00" + (~ ~(r * 255)).toString(16)).slice(-2) + ("00" + (~ ~(g * 255)).toString(16)).slice(-2) + ("00" + (~ ~(b * 255)).toString(16)).slice(-2); return (c); }