User talk:Pathoschild/Scripts/Regex menu framework
Add topicEnglish Wikipedia and the modern skin
[edit]Hi, I enabled it on English Wikipedia, however it doesnt work with the modern skin. As a result I have removed it in order to avoid users reporting odd errors all over the place.
I think this is the changed required:
- sidebar = document.getElementById('column-one'); + sidebar = document.getElementById('p-cactions').parentNode;
John Vandenberg 10:27, 25 April 2009 (UTC)
- Fixed. —Pathoschild 03:04:25, 26 April 2009 (UTC)
Bug?
[edit]When I use the custom regex form with Search #1 = /\n\s*/g
and Replace #1 = \n
in a page with, say
A B C D E
I get
A\nB\nC\nD\nE
instead of
A B C D E
Is it normal? How could I replace something by line breaks? Helder 20:46, 20 September 2009 (UTC)
- For the replacement don't use the escaped characters, just add the formatting that you want, eg. in this case a carriage return. billinghurst sDrewth 12:54, 7 March 2010 (UTC)
Gadget
[edit]This is now available as a gadget under user preferences on English Wikipedia. Could you update the documentation to cover that case? How to add permanents scripts? --Apoc2400 13:08, 22 September 2009 (UTC)
- It is covered on the main page, or you can have a look at my rudimentary attempts (down at the bottom of en:s:User:Billinghurst/monobook.js billinghurst sDrewth 13:08, 7 March 2010 (UTC)
Capture repetitve code (future wish)
[edit]When undertaking works at Wikisource, there is often occasions where one is wanting to repeat S&R during the same session, and encoding it into monobook.js is a PITA. It would be very cool if there was the means to capture multiple little regex search and replacements for future use, even if just during a session to save having to keep a separate paste list. An example of the sort of thing is .../\B'|'\ /g... to ..."... which is just for the current work on which I am working, however, it is about every second page. billinghurst sDrewth 12:59, 7 March 2010 (UTC)
Change collapsible to expanded?
[edit]Would it be possible to change the default setting of collapsible in the leftnav to expanded by default - or allow the user to change it if they wish? Anyone have any tips on how to manually do this without having to reimport the whole JS?
--Varnent 23:30, 16 July 2011 (UTC)
- You can add the following line to your
function rmflinks()
as I did here:
$('#p-regex').addClass( 'expanded' ).removeClass( 'collapsed' ).find( 'div.body' ).show();
- It is based on the toogle function from Vector/modules/ext.vector.collapsibleNav.js. Helder 15:06, 21 July 2011 (UTC)
- Excellent - that worked - thank you! --Varnent 23:02, 3 August 2011 (UTC)
Import just once
[edit]I have installed several scripts each of which depends on this framework and imports it. This results in duplicated menu entries and quite possibly slows page loading down, although everything still seems to work. What is the right way to ensure that this framework is imported only once if necessary? Please can you update the documentation accordingly? (I will notify the other script author of this thread and I'm watching this page). Thanks. --Mirokado (talk) 13:26, 19 May 2012 (UTC)
- You did not specify what exactly was duplicated, but I suspect that it may be caused by
'custom Regex'
, the only function that seems to call up a menu button in the left-hand sidebar; I have often wondered why I had two "Custom Regex
" sidebar buttons. I have found that each script reliant on any other script must import it independently for it to function. TO that end, Framework must be imported into each of my scripts so that I may use for example 'regex
' instead of 'txt.value=txt.value.replace
'. I don't know how practical it will be, but one possible solution is to eject that function to another script to be imported separately. Incidentally, thanks to Helder for introducing me to Framework; perhaps he has a suggestion too? Cheers. --Ohconfucius (talk) 14:23, 19 May 2012 (UTC)
- Pathoschild, I think the line
function rfmenu(rfmconfig) {
- should be replaced by
function rfmenu(rfmconfig) {
if ( document.getElementById('p-regex') !== null ){
// Already loaded
return;
}
- It is also recommended to explicitly indicate with "
window.<some variable name>
" which variables are assumed to be globals (e.g.:editbox
→window.editbox
,editreason
→window.editreason
, etc...) - Ohconfucius, I think you should make sure your scripts are compatible with the latest version of MediaWiki. For example, replace
- It is also recommended to explicitly indicate with "
importScriptURI('http://meta.wikimedia.org/w/index.php?title=User:Pathoschild/Scripts/Regex_menu_framework.js&action=raw&ctype=text/javascript');
- by
mw.loader.load( '//meta.wikimedia.org/w/index.php?title=User:Pathoschild/Scripts/Regex_menu_framework.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400' );
- on your scripts.
- There are other tips listed under mw:ResourceLoader/Migration guide (users) (and a helper tool is mentioned on User:Krinkle/Le Tour de Wikí/2011 Resource Walker#2011 Resource Walker: Checklist).
- I hope this helps. Helder 14:55, 20 May 2012 (UTC)
- I attempted that change to the import instruction and ended up with eight duplicated sidebar tabs (and related buttons) for scripts, so I reversed the change. Humpf! I need to study this further... --Ohconfucius (talk) 08:19, 22 May 2012 (UTC)
- Have you tried using only one "mw.loader.load" on your vector.js (or common.js), before importing the other scripts (and removing the corresponding "mw.loader.load" from them)? I think it is unnecessary to load the regex framework more than once for each user. Helder 12:05, 22 May 2012 (UTC)
- Hi Mirokado. I'll prioritise merging the "custom regex" tool into TemplateScript this week, since it's the last feature not yet merged. Once that's done you can switch to using TemplateScript, which does prevent itself from initializing multiple times. In the meantime Helder's suggestion above should work. —Pathoschild 03:57, 23 May 2012 (UTC)
- Thanks, I'll watch for the merge. --Mirokado (talk) 18:02, 23 May 2012 (UTC)
- The merge is done. Let me know if you'd like me to migrate your scripts, or if you encounter any issues with the new features. —Pathoschild 02:59, 27 May 2012 (UTC)
- Thanks, that is working fine, I like the store functionality. --Mirokado (talk) 01:21, 28 May 2012 (UTC)
Error since 18 November 2023
[edit]Since the edit on 18 November 2023 by User:Jon (WMF) I get a quick flash of an error message on every page I edit on the English Wikipedia. The message is:
https://meta.wikimedia.org/w/index.php?title=User:Pathoschild/Scripts/Regex_menu_framework.js&action=raw&ctype=text/javascript at line 0: Script error.
I guess it's coming from one of en:User:Ohconfucius's scripts I have installed; either en:User:Ohconfucius/script/MOSNUM dates.js or en:User:Ohconfucius/script/Common Terms.js. Can anything be done about this? -- Michael Bednarek (talk) 07:10, 18 November 2023 (UTC)
- Now fixed. Thank you User:Magog the Ogre and User:M7. -- Michael Bednarek (talk) 14:10, 19 November 2023 (UTC)