Jump to content

User:Richardguk/Test.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
if (document.URL.getParamValue('rgukToAdd')) {
 var newtext=document.URL.getParamValue('rgukToAdd');
 var myelm=document.getElementById('wpTextbox1');
 var myvar1=myelm.value;
 var myvar2=myvar1.replace(/^([^]*)(\s*category\s*:[^\]]*]].*)(.*?)$/igm, '$1$2\n'   newtext   '$3');
 alert('was:'  myvar1.length   ' plus:' newtext.length ' =' (myvar1.length newtext.length) ' new:' myvar2.length);
 myelm.value=myvar2;
 myelm.focus();
 myelm.setSelectionRange(myelm.value.length,myelm.value.length);
}