User:Allstarecho/wpms.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 (wpmsAddText == null) var wpmsAddText = '{'+'{WikiProject Mississippi|class=?|importance=?|needs-infobox=?|needs-photo=?|listas=?, ?}'+'}\n\n';
if (wpmsSummary == null) var wpmsSummary = 'Add [[WP:MS]] project tag';
 
function addwpmsText() {
  var box = document.getElementById('wpTextbox1');
  var content = box.value;
  content = wpmsAddText + content;
  box.value = content;
 
  var sumBox = document.getElementById('wpSummary');
  sumBox.value = wpmsSummary;
}
 
function goTowpms() {
  var url = mw.config.get('wgServer') + mw.config.get('wgScript') + '?title=' + wgPageName + '&action=edit&addwpms=true'; 
  window.location = url;
}
 
function attachwpmsLink() {
  var wpmsLink = new wa_element('li');
  wpmsLink.ele_obj.id = 't-wpms';
  wpmsLink.ele_obj.innerHTML = '<a href="#" title="Add WPMS tag">Add WPMS tag</a>';
  wpmsLink.addScriptEvent('click', function() { goTowpms(); });
 
  wpmsLink.attach(document.getElementById('pt-userpage'), 'before');
}
 
importScript('User:Ale_jrb/Scripts/waLib.js'); 
hookEvent('load', attachwpmsLink);
if (window.location.href.indexOf('&addwpms=true') > -1) { hookEvent('load', addwpmsText); }