Jump to content

User:GhostInTheMachine/SDsummary.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by GhostInTheMachine (talk | contribs) at 17:18, 31 July 2022 (create SDsummary.js). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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.
//  add CSS
mw.util.addCSS("button.SDsummaryButton { margin-top: 5px; margin-right: 5px; } ");

//  where to put the buttons
var SDsummaryBox = $('#contentSub');

//  list of buttons
[

"SDSHORT    # Shorten Short description per [[WP:SDSHORT]]",
"SDNONE     # Short description=none per [[WP:SDNONE]]"

]

//  use the list to create buttons
.forEach(function(s){
  var w = s.split('#');
  var b = $('<button class="SDsummaryButton" data-text="' + w[1].trim() + '">' + w[0].trim() + '</button>');
  SDsummaryBox.append(b);
  b.click(SDsummaryPaste);
});

//  button click code to set the summary
function SDsummaryPaste(){
  $('#sdh-summarybox>input').val($(this).data('text'));
}