User:Mr.Z-man/feedbacktab.js

// Feedback tab on article pages // To-do, some sort of explanation thing, see what other people want

function feedbackTab { //Only load on articles, will add in a thing to limit to unregistered users later if (mw.config.get('wgNamespaceNumber') == 0 ) { mw.util.addPortletLink('p-cactions', mw.config.get('wgScript') + '?title=Talk:' + mw.config.get('wgTitle') + '&action=edit&section=new&feedback=1', "feedback", "ca-feedbacktab", "Leave feedback for this article"); }

if (mw.config.get('wgNamespaceNumber') == 1 && document.URL.indexOf('feedback=1') != -1) { // Hide stuff that will just confuse the user and get in the way if (getElementsByClassName(document, "div", "mw-newarticletext")[0]) { getElementsByClassName(document, "div", "mw-newarticletext")[0].style.display = 'none'; } document.getElementById('editform').style.visibility= 'hidden'; document.getElementById('wpTextbox1').style.width = '0' document.getElementById('wpTextbox1').style.height = '0' document.getElementById('editpage-specialchars').style.display = 'none'; document.getElementById('editpage-copywarn').style.display = 'none'; document.getElementById('editpage-copywarn2').style.display = 'none'; document.getElementById('editpage-copywarn3').style.display = 'none'; document.getElementById('toolbar').style.display= 'none'; document.getElementById('talkpagetext').style.display = 'none'; document.getElementById('wpSummary').style.display = 'none'; document.getElementById('wpSummaryLabel').style.display = 'none'; getElementsByClassName(document, "div", "editButtons")[0].style.display = 'none';

// Change the page appearance document.title = 'Feedback on ' + mw.config.get('wgTitle') + ' - Wikipedia, the free encyclopedia'; document.getElementsByTagName('h1')[0].innerHTML = 'Feedback on ' + mw.config.get('wgTitle');

// Get the text of some important stuff we hid to insert later copyright = document.getElementById('editpage-copywarn').innerHTML; bottom = document.getElementById('editpage-copywarn2').innerHTML;

//Create the form form = ''+ ' '+ ' ';  form += copyright; form += bottom;

// Add the form document.getElementById('wikiPreview').innerHTML += form;

}     }

function feedbackSubmit { //Intercept the form submit and put stuff in the edit box var feed = document.getElementById('feedbackform'); q = feed.quality.value; p = feed.problems.value; sug = feed.suggestions.value; c = feed.comments.value; sou = feed.sources.value;

text = '\'\'\'Quality:\'\'\' ' + q + '\n\n'+ '\'\'\'Problems:\'\'\' ' + p + '\n\n'+ '\'\'\'Suggestions:\'\'\' ' + sug + '\n\n'+ '\'\'\'Comments:\'\'\' ' + c + '\n\n'+ '\'\'\'Sources:\'\'\' ' + sou + '\n\n-- '+''; // Save the page document.getElementById('wpSummary').value = 'Article Feedback'; document.getElementById('wpTextbox1').value = text; document.editform.wpSave.click }

// Setting the form action to the talk page URL sends us to the page before we save, // an empty function will save the page normally and provide an anchor to the new section. // Could probably put an alert or something here, but that would just be annoying. function feedbackDummyFunction { }

$(feedbackTab);