Community Central
Community Central
mNo edit summary
No edit summary
Line 12: Line 12:
 
appendSignature = function () {
 
appendSignature = function () {
 
if ($('input#wpMinoredit').is(':checked')) return;
 
if ($('input#wpMinoredit').is(':checked')) return;
editorInstance.setContent( editorInstance.getContent() +
+
switch (editorInstance.mode) {
' -- ~~' + String.fromCharCode(126) + '~'
+
case 'wysiwyg':
  +
editorInstance.getEditbox().append('-- ~~' + String.fromCharCode(126) + '~');
);
 
  +
break;
  +
case 'source':
  +
editorInstance.setContent( editorInstance.getContent() +
  +
' -- ~~' + String.fromCharCode(126) + '~'
  +
);
  +
break;
 
}
 
}
 
}
 
$('input#wpSave').click(appendSignature);
 
$('input#wpSave').click(appendSignature);
Line 25: Line 32:
   
 
To install the script go to your [[Special:Mypage/global.js|global.js]] and copypaste the code from here to there. You will need to [[w:c:dev:Hard_Refresh|refresh]] both global.js and the test page. You may also have to wait a while for the script to take effect or [[Help:Purge|purge]] manually. I'm not certain about the latter.
 
To install the script go to your [[Special:Mypage/global.js|global.js]] and copypaste the code from here to there. You will need to [[w:c:dev:Hard_Refresh|refresh]] both global.js and the test page. You may also have to wait a while for the script to take effect or [[Help:Purge|purge]] manually. I'm not certain about the latter.
  +
  +
Note: If you ''don't'' want to have your post signed, check "Minor edit".
   
 
Let me know whether it does or does not work! Suggestions and critique are welcome too!
 
Let me know whether it does or does not work! Suggestions and critique are welcome too!
Line 31: Line 40:
   
   
UPDATE: If you check "Minor edit" your post will not be signed. -- [[User:Pecoes|Pecoes]] 07:03, March 9, 2012 (UTC)
+
UPDATE: added check for input#wpMinoredit. -- [[User:Pecoes|Pecoes]] 07:03, March 9, 2012 (UTC)
  +
  +
UPDATE: replaced call to editorInstance.setContent() with call to editorInstance.getEditbox().append() for WYSIWYG editor

Revision as of 09:24, 9 March 2012

Forums: Admin Central Index Watercooler Testers needed for automated signature!
Central's forums are a place for the community to help other members.
To contact staff directly or to report bugs, please use Special:Contact.
Note: This topic has been unedited for 4424 days. It is considered archived - the discussion is over. Do not add to unless it really needs a response.



I'm the sort of person who constantly forgets to sign his posts. But I'm also a programmer and as such I fail to see why I should do what a script could do in my stead. This is this script:

$(function () {
    var talkNameSpaces = [1,3,5,7,9,11,13,15,110,111,114,401,500,501,502,503];
    if (-1 < $.inArray(wgNamespaceNumber, talkNameSpaces) && 'edit' == $.getUrlVar('action')) {
        appendSignature = function () {
            if ($('input#wpMinoredit').is(':checked')) return;
            switch (editorInstance.mode) {
                case 'wysiwyg':
                    editorInstance.getEditbox().append('-- ~~' + String.fromCharCode(126) + '~');
                break;
                case 'source':
                    editorInstance.setContent( editorInstance.getContent() +
                        ' -- ~~' + String.fromCharCode(126) + '~'
                    );
                break;
            }
        }
        $('input#wpSave').click(appendSignature);
        $('a#publish').click(appendSignature);
    }
});

Or at least I hope it is. I did test it and it does seem to work. But it would be helpful if a few others would test it as well before I publish it at the dev wiki.

To install the script go to your global.js and copypaste the code from here to there. You will need to refresh both global.js and the test page. You may also have to wait a while for the script to take effect or purge manually. I'm not certain about the latter.

Note: If you don't want to have your post signed, check "Minor edit".

Let me know whether it does or does not work! Suggestions and critique are welcome too!

-- Pecoes 06:29, March 9, 2012 (UTC)


UPDATE: added check for input#wpMinoredit. -- Pecoes 07:03, March 9, 2012 (UTC)

UPDATE: replaced call to editorInstance.setContent() with call to editorInstance.getEditbox().append() for WYSIWYG editor