User:Christian Sirolli/global.js

massCategorizationDelay = 1000; nullEditDelay = 1; window.AdvancedOasisUI = { accountNavFollowedPages: true, accountNavWatchlist: true, categoryRedlink: true, RCHeader: true, DefaultSourceMode: true, lightbox: true, activity2RC: true, userLang: true, }; importArticles({   type: 'script',    articles: [        'u:dev:NullEditButton/code.js',        'u:dev:Bglinks.js',        'u:dev:AutoEditPages/code.js',        'u:dev:UnsafeScripts/code.js',        'u:dev:AntiUnicruft/code.js',        'u:dev:PortableCSSPad/code.js',        'u:dev:ReferencePopups/code.js',        'u:dev:CategoryRenameAuto-update/code.js',        'u:dev:MediaWiki:MassNullEdit/code.js',        'u:dev:MediaWiki:Rollback/code.js',        'u:dev:MediaWiki:MassCategorization/code.js',        'u:dev:MediaWiki:Wikimarks/code.js',        /*'u:dev:AjaxPatrol/code.js',*/        'u:community:User:Cizagna/ajaxpatrollinks.js',        'u:dev:UserTalkNotifications/code.js',        'u:dev:EditIntroButton/code.js',        'u:dev:AdvancedOasisUI/code.js',    ] }); importScriptURI('//en.wikipedia.org/w/index.php?title=User:Joeytje50/JWB.js/load.js&action=raw&ctype=text/javascript'); importScriptURI('//en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js' + '&action=raw&ctype=text/javascript'); /* jQuery Ajax Patrol Links @author Grunny */ function ajaxPatrolLinks { $( 'body' ).on( 'click', '.patrollink', function ( e ) {		e.preventDefault;		var	$patrolLink = $( this ).children( 'a' ),			$url = $patrolLink.attr( 'href' );		$patrolLink.html( '' );		$.get( $url, function { $patrolLink.removeAttr( 'href' ).css( 'color', 'grey' ).text( 'Marked as patrolled' ); } );	} ); } $( ajaxPatrolLinks ); /*See user page for more info.*/ function ajaxPatrolLinks { var a = document.evaluate('//span[@class="patrollink"]/a', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; // dif article var b = document.evaluate('//div[@class="patrollink"]/a', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; // new article if (b) a = b;	if (a) { var div = a.parentNode; div.style.cssText = 'color:Crimson'; var url = a.href; a.onclick = function (event) { var aj = sajax_init_object; if (aj) { while (div.firstChild) { div.removeChild(div.firstChild) } div.appendChild(document.createTextNode('[Marking as patrolled...]')); aj.onreadystatechange = function { if (aj.readyState == 4 && aj.status == 200) { while (div.firstChild) { div.removeChild(div.firstChild) } div.style.cssText = 'color:Silver'; div.appendChild(document.createTextNode('[Marked as patrolled]')); aj.onreadystatechange = null; }				};				aj.open("GET", url, true); aj.send(null); return false; }		};	} } addOnloadHook(ajaxPatrolLinks);

/******************************************************************************/

// Please suggest improvements / translations on the talk page. $(function {   'use strict';    importArticle({ type: "style", article: "u:dev:FindAndReplace/code.css" });   var lng = {        en: {// English (English)            far: 'Find and replace',            farbuttontext: 'Find and Replace Text',            farselbuttontext: 'Find and Replace selected Text',            selectedtext: 'Selected text:',            findthis: 'Find this:',            replacewith: 'Replace with:',            globalm: 'Global matching.',            casesensitive: 'Case sensitive.',            enblregex: 'Enable regular expressions', // New, needs translation            undoedits: 'Undo edits',            undoinfo: 'All edits, not only replaces',            collapse: 'Collapse',            expand: 'Expand',            lbwarning: 'Warning: pressing Enter key\nwill publish your edits',            farfound: 'found and replaced.',            undomsg: 'This will undo all edits, not only text replacements.\r\nAre you sure you want to undo?',            noselected: 'No selected text.' },   };    var st = $.storage.get("FindAndReplace"), cvGM = window.cvGlobalMatching || 'checked', cvCS = window.cvCaseSensitive || 'unchecked', cvRG = window.cvEnableRegex || 'unchecked', selectedText = "", contengut = document.getElementById("wpTextbox1"), debuta, fin; if (typeof st !== 'object' || st === null) st = {sh: false, gm: true, cs: false}; lng = $.extend(lng.en, lng[mw.config.get('wgContentLanguage')], lng[mw.config.get('wgUserLanguage')]); $('.rail-auto-height').prepend(' ' + lng.far + ' (' + (st.sh ? lng.collapse : lng.expand) + ')   ' + lng.findthis + '  ' + lng.replacewith + '      ' + lng.selectedtext + '   ' + lng.undoedits + '   '); $(window).resize(function {       $('#findfielddiv').height($(window).height - 250 - $('.module_content').height);    }); $(window).trigger('resize'); $('#find-and-replace').click(function {        var searchfor = ,            searchexp,            $textarea = $('#wpTextbox1'),            replacewith = $('#replace_with').val.replace(/\r/gi, ),            text = $textarea.val.replace(/\r/gi, ),            flagg = 'g',            flagi = 'i',            enableregex = 0;        if ($('#globl').prop('checked') === false) {            flagg = ;        }        if ($('#case_sen').prop('checked') === true) {            flagi = ;        }        if ($('#regex_search').prop('checked') === true) {            enableregex = 1;        }        var flags = flagg + flagi + 'm';        if(enableregex === 1) {            searchfor = $('#find_this').val;        } else {            searchfor = $('#find_this').val.replace(/\r/gi, ).replace(/([.*+?^=!:${}|\[\]\/\\])/g,'\\$1');        }        searchexp = new RegExp(searchfor, flags); var rcount = 0; var matched = text.match(searchexp); if (matched !== null) { rcount = matched.length; }       text = text.replace(searchexp, replacewith); $textarea.val(text); $('#far-found').text( rcount + ' ' + lng.farfound ); });   function getSelectedText {        var texte = "";        if (window.getSelection) {            texte = window.getSelection.toString;        } else if (document.selection && document.selection.type != "Control") {            texte = document.selection.createRange.text;        }        if(texte === "") {            texte = selectedText;        }        return texte;    }    $('#wpTextbox1').bind('mouseup keyup mouseleave', function{ selectedText = getSelectedText; debuta = contengut.selectionStart; fin = contengut.selectionEnd; $('#texteselectionne').text(selectedText); });   $('#find-and-replace-selected').click(function  { if(selectedText === "") { alert(lng.noselected); }       var searchfor = '', searchexp, searchexp2, letexte, selectedText2, $textarea = $('#wpTextbox1'), replacewith = $('#replace_with').val.replace(/\r/gi, ''), text = $textarea.val.replace(/\r/gi, ''), flagg = 'g', flagi = 'i', enableregex = 0;

if ($('#globl').prop('checked') === false) { flagg = ''; }       if ($('#case_sen').prop('checked') === true) { flagi = ''; }       var flags = flagg + flagi + 'm'; if(enableregex === 1) { searchfor = $('#find_this').val; } else { searchfor = $('#find_this').val.replace(/\r/gi, '').replace(/([.*+?^=!:${}|\[\]\/\\])/g,'\\$1'); }       searchexp = new RegExp(searchfor, flags); selectedText2 = selectedText.replace(/\r/gi, '').replace(/([.*+?^=!:${}|\[\]\/\\])/g,'\\$1'); searchexp2 = new RegExp(selectedText2, 'im'); var rcount = 0; var matched = selectedText.match(searchexp); if (matched !== null) { rcount = matched.length; }       letexte = selectedText.replace(searchexp, replacewith); text = text.substring(0, debuta) + letexte + text.substring(fin); $textarea.val(text); $('#far-found').text( rcount + ' ' + lng.farfound ); selectedText = letexte; $('#texteselectionne').text(selectedText); });   function getOldContent {        $("#wpTextbox1").val($("#wpTextbox1").text);    }    $('a#far-undo').click(function  { if (confirm(lng.undomsg)) getOldContent; });   $(".far-module h3").click(function  { var $header = $(this); var $content = $header.next; var $visible = $content.is(":visible"); $header.find('span').text(lng.far + " (" + ($visible ? lng.expand : lng.collapse) + ")"); $header.find(".chevron").addClass($visible ? "expand" : "collapse").removeClass($visible ? "collapse" : "expand"); $content.stop.slideToggle(500); });   $(window).bind("beforeunload", function{ $.storage.set("FindAndReplace", {sh: $("#findfielddiv").is(":visible")}); }); });