MediaWiki:DRN-wizard.js: Difference between revisions

Content deleted Content added
per request: https://en.wikipedia.org/w/index.php?title=MediaWiki_talk%3AGadget-DRN-wizard.js&type=revision&diff=715153272&oldid=609069369
per tper
 
(21 intermediate revisions by 7 users not shown)
Line 1:
// <nowiki>
// 2020-03-09 - deconverted from Gadget, is only used on 1 page and is now being called direct from [[Wikipedia:Dispute resolution noticeboard/request]]
 
/**
* This is the main object that holds the state for everything
Line 19:
 
//Involved users
this.involved_users = [mw.config.get( 'wgUserName' ) + ', '];
 
//Previous forums
Line 35:
 
$( '#drwContent1' ).append( '<h3>Location of dispute</h3>' );
$( '#drwContent1' ).append( '<p>Please provide athe linkname toof the talkarticle pageor sectionpage where discussionthe hasdispute occurredis located.<br> Note:For example, if athe suitabledispute discussionwas linkon isthe notarticle providedAustralia, yourenter DRNin filing<b>Australia</b> mayin bethe automaticallybox, not closed.<nowiki>[[Australia]]</pnowiki> or https://en.wikipedia.org/wiki/Australia' );
 
var inputbox = $( document.createElement( 'input' ) );
Line 56:
 
$( '#drwContent1' ).append( '<h3>Dispute overview</h3>' );
$( '#drwContent1' ).append( '<p>Can you give us a quickan explanation of what is going on? What is the issue you are bringing to dispute resolution?</p>' );
 
var desc = $( document.createElement( 'textarea' ) );
Line 69:
gDRW.dispute_description = this.value;
} );
desc.bindon( 'keyup', function() {
$( '#taCount' ).text( '' + this.value.length + ' / 2000' );
} );
Line 75:
$( '#drwContent1' ).append( desc );
 
$( '#drwContent1' ).append( $( '<p id="taCount">' + this.dispute_description.length + ' / 2000</p>' ) );
};
 
Line 89:
type: 'text',
name: 'involved_users',
value: this.involved_users.join( ', ' )
} );
 
inputbox.change( function() {
gDRW.involved_users = this.value.split( ',' ).map( function ( involved_user ) { return involved_user.trim(); } );
} );
 
Line 104:
 
$( '#drwContent1' ).append( '<h3>Resolving the dispute</h3>' );
$( '#drwContent1' ).append( '<p>What other steps, if any, have you tried to resolve thisthe dispute? so far. Please provide a link to where these discussions have occurred, separated by a comma or new line. For example:</pbr>' );
$( '#drwContent1' ).append('<ul>' +
'<li><nowiki>[[Talk:Australia#Removal_of_Chief_Justice_from_Infobox]]</li>' +
'<li><nowiki>[https://en.wikipedia.org/wiki/Talk:Australia#Removal_of_Chief_Justice_from_Infobox Talk:Australia]</li>' +
'</ul>' );+
$( '#drwContent1' ).append( '<u>At a minimum, recent extensive discussion needs to have taken place on the talk page of the page in question.</u><br><font color="red"><b>Note: If a suitable discussion link is not provided, your request may be automatically closed.</b></font></p>' );
 
var desc = $( document.createElement( 'textarea' ) );
Line 117 ⟶ 122:
gDRW.previous_forums = this.value;
} );
desc.bindon( 'keyup', function() {
$( '#pcCount' ).text( '' + this.value.length + ' / 500' );
} );
Line 123 ⟶ 128:
$( '#drwContent1' ).append( desc );
 
$( '#drwContent1' ).append( $( '<p id="pcCount">' + this.previous_forums.length + ' / 500</p>' ) );
};
 
Line 143 ⟶ 148:
gDRW.desired_outcome = this.value;
} );
desc.bindon( 'keyup', function() {
$( '#ocCount' ).text( '' + this.value.length + ' / 500' );
} );
 
$( '#drwContent1' ).append( desc );
$( '#drwContent1' ).append( $( '<p id="ocCount">' + this.desired_outcome.length + ' / 500</p>' ) );
};
 
Line 167 ⟶ 172:
//Users involved
$( '#drwContent1' ).append( '<h3>Users involved</h3>' );
$( '#drwContent1' ).append( $( '<p></p>' ).text( this.involved_users.join(', ') ) );
 
//Previous forums
$( '#drwContent1' ).append( '<h3>Resolving the dispute</h3>' );
$( '#drwContent1' ).append( '<h4>OtherPrevious steps if any, you have tried to resolve thisthe dispute</h4>' );
$( '#drwContent1' ).append( $( '<p></p>' ).text( this.previous_forums ) );
 
Line 184 ⟶ 189:
this.getWikitextReport = function() {
//Returns string of wikitext for submission to DR page
var report = "{{DR case status}}\n{{drn filing editor|{{subst:REVISIONUSER}}|~~~~~}}\n{{subst:DNAU|1428}}<!-- PLEASEREMEMBER TO REMOVE THE PREVIOUS COMMENT WHEN CLOSING THIS THREAD. (Otherwise the thread won't be archived until the date shown.)! -->\n{{drn filing editor|{{subst:REVISIONUSER}}|~~~~~}}\n\n";
 
//On Talk Page
Line 197 ⟶ 202:
report += '* {{pagelinks|' + articleArray[ articleIndex ] + '}}\n';
}
 
//Involved users
report += "<span style=\"font-size:110%\">'''Users involved'''</span>\n";
var userArray = this.involved_users.split( ',' );
var userIndex;
for ( userIndex = 0; userIndex < userArraythis.involved_users.length; userIndex++ )
{
var user = userArraythis.involved_users[ userIndex ];
user = user.trim();
if ( user ) {
Line 216 ⟶ 220:
 
//Previous forums
report += "<span style=\"font-size:110%\">'''HaveHow have you tried to resolve this previouslydispute before coming here?'''</span>\n";
report += '\n'+ this.previous_forums + '\n\n';
 
//Desired Outcome
report += "<span style=\"font-size:110%\">'''How do you think we can help resolve the dispute?'''</span>\n";
report += '\n' + this.desired_outcome + '\n\n';
 
//User statements
var currentUser = mw.config.get( 'wgUserName' );
for ( userIndex = 0; userIndex < userArraythis.involved_users.length; userIndex++ ) {
var userArrayuser = this.involved_users.split([ ','userIndex )];
{
if ( userArray[ userIndex ]user != currentUser ) {
report += '==== Summary of dispute by ' + userArray[ userIndex ]user + " ====\n<div style=\"font-size:smaller\">Please keep it brief - less than 2000 characters if possible, it helps us help you quicker.</div>\n\n";
}
}
 
//Discussion
Line 244 ⟶ 248:
var s2_active = ( this.wizard_step == 2 ) ? ' pr-active' : '';
var s3_active = ( this.wizard_step == 3 ) ? ' pr-active' : '';
var s4_active = ( this.wizard_step == 4 ) ? ' pr-active' : '';
 
 
Line 250 ⟶ 255:
signupbox += '<li class="pr-spacer' + s1_active + '"><div></div></li>';
 
signupbox += '<li class="s2' + s2_active + '"><span class="pr-number">2</span><span>DescriptionType of dispute</span></li>';
signupbox += '<li class="pr-spacer' + s2_active + '"><div></div></li>';
 
signupbox += '<li class="s3s2' + s3_active + '"><span class="pr-number">3</span><span>SummaryDescription</span></li>';
signupbox += '<li class="pr-spacer' + s3_active + '"><div></div></li>';
 
signupbox += '<li class="s4' + s4_active + '"><span class="pr-number">4</span><span>Summary</span></li>';
signupbox += '<li class="pr-spacer' + s4_active + '"><div></div></li>';
signupbox += '</ul>';
 
Line 287 ⟶ 295:
 
'Hi there. This form can be used to file a request at the dispute resolution noticeboard, a venue for resolving disputes over article content between two or more editors. ' +
'It is unable to address disputes primarily concerning user conduct - they should be discussed with the users involved first, and failing that directed <a href="httphttps://en.wikipedia.org/wiki/WP:ANI">here</a>. ' +
'If you have any questions please ask one of our <a href="httphttps://en.wikipedia.org/wiki/WP:DRVOLUNTEERS">volunteers</a> for guidance.' +
 
'<h3>In brief: dispute resolution should be used when you:</h3>' +
Line 302 ⟶ 310:
'<ul>' +
'<li>Help provide suggestions on content</li>' +
'<li>FrameProvide discussionseditors andwith offerguidance supporton forapplicable partiespolicies thatand wantguidelines to work towardsthe adispute compromise</li>' +
'<li>Mediate discussions and assist editors work towards a consensus on the disputed content</li>' +
'<li>Provide a structured environment with oversight, to allow editors to work together with experienced input</li>' +
'</ul>' +
 
Line 311 ⟶ 321:
'<li>Remove content that you don\'t like from articles</li>' +
'<li>Force another editor to do something</li>' +
'<li>Address disputes that are currently under discussion somewhere else (such as <a href="httphttps://enwpen.wikipedia.org/wiki/WP:RFC">Requests for Comment</a>, <a href="http://enwp.org/WP:M">Mediation</a> or <a href="httphttps://enwpen.wikipedia.org/wiki/WP:RFAR">Arbitration</a>)</li>' +
 
'</p>' +
Line 318 ⟶ 328:
);
 
var buttons = '<a href="#top" class="button1" id="yesClickButtonyesContentClickButton">Yes, it has.</a>';
buttons += ' <a href="#top" class="button1" id="showCancelButton">Not yet.</a>';
$( '#drwButtons' ).html( buttons );
 
$( '#yesClickButtonyesContentClickButton' ).click( yesClickyesContentClick );
$( '#showCancelButton' ).click( showCancel );
}
 
function showStep2( errorMsg ) {
 
function showStep2( errorMsg ) {
 
gDRW.wizard_step = 2;
 
$( '#drwProgressBar' ).html( gDRW.getProgressBar() );
 
$( '#drwContent1' ).html(
'<h2>Types of dispute</h2>' +
 
'<p>This forum is designed to only assist with issues regarding the content of articles and isn\'t able to assist with concerns about other editors\' behaviour. Is this an issue only about another editor\'s behaviour?.</p>'
);
 
var buttons = '<a href="#top" class="button1" id="yesConductClickButton">Yes, it is about another user.</a>';
buttons += ' <a href="#top" class="button1" id="showContentDisputeForm">No, it is not.</a>';
$( '#drwButtons' ).html( buttons );
 
$( '#yesConductClickButton' ).click( showConductCancel );
$( '#showContentDisputeForm' ).click( showStep3 );
}
 
function showStep3( errorMsg ) {
 
gDRW.wizard_step = 3;
$( '#drwProgressBar' ).html( gDRW.getProgressBar() );
 
var intro = '';
 
if ( typeof errorMsg !=== 'undefinedstring' ) {
intro = '<p class="warning">' + errorMsg + '</p>';
}
Line 361 ⟶ 390:
var buttons = '<a href="#top" class="button1" id="showStep1Button">Back</a>';
buttons += ' <a href="#top" class="button1" id="showCancelButton">Cancel</a>';
buttons += ' <a href="#top" class="button1" id="showStep3ButtonshowStep4Button">Next</a>';
 
$( '#drwButtons' ).html( buttons );
Line 367 ⟶ 396:
$( '#showStep1Button' ).click( showStep1 );
$( '#showCancelButton' ).click( showCancel );
$( '#showStep3ButtonshowStep4Button' ).click( showStep3showStep4 );
}
 
function showStep3showStep4() {
 
var inputErrors = [];
Line 388 ⟶ 417:
}
if ( inputErrors.length > 0 ) {
return showStep2showStep3( 'All fields are required. Missing values for: ' + inputErrors.join( ', ' ) );
}
 
gDRW.wizard_step = 34;
$( '#drwProgressBar' ).html( gDRW.getProgressBar() );
 
Line 399 ⟶ 428:
 
 
var buttons = '<a href="#top" class="button1" id="showStep2ButtonshowStep3Button">Edit</a>';
buttons += ' <a href="#top" class="button1" id="showCancelButton">Cancel</a>';
buttons += ' <a href="#top" class="button1" id="doSubmitButton">Save</a>';
Line 405 ⟶ 434:
$( '#drwButtons' ).html( buttons );
 
$( '#showStep2ButtonshowStep3Button' ).click( showStep2showStep3 );
$( '#showCancelButton' ).click( showCancel );
$( '#doSubmitButton' ).click( doSubmit );
Line 422 ⟶ 451:
//Show error
$( '#drwContent1' ).html( '<h2>Error</h2><p>Sorry, there was an error attaching your request. Maybe try it again?</p>' );
$( '#drwButtons' ).html( '<a href="#top" class="button1" id="showStep3ButtonshowStep4Button">Back to Summary</a>' );
$( '#showStep3ButtonshowStep4Button' ).click( showStep3showStep4 );
} else {
$( '#drwContent1' ).html( '<h2>Error</p><p>Something went wrong!</p>' );
Line 429 ⟶ 458:
}
}
 
 
function showCancel() {
Line 439 ⟶ 467:
'<p>' +
'It\'s best to discuss your concerns with the other users on the talk page of the article before seeking dispute resolution. ' +
'You can find instructions on how to do this at <a href="httphttps://en.wikipedia.org/wiki/WP:DISCUSSIT">this page,</a> or you can place <code>{{helpme}}</code> on <a href="httphttps://enwpen.wikipedia.org/wiki/Special:MyTalk">your own talk page</a>, and a volunteer will come by your page to help.' +
'</p>'
);
$( '#drwButtons' ).html( '<a href="#top" class="button1" id="showStep1Button">Start Over</a>' );
$( '#showStep1Button' ).click( showStep1 );
}
 
function showConductCancel() {
 
gDRW.wizard_step = 0;
$( '#drwProgressBar' ).html( gDRW.getProgressBar() );
 
$( '#drwContent1' ).html(
'<p>' +
'We can only assist with content disputes. If you have concerns about the conduct of another editor, you will need to bring this to the <a href="https://en.wikipedia.org/wiki/WP:AN">Administrator\'s Noticeboard.</a>' +
'</p>'
);
Line 465 ⟶ 507:
* gDRW.previous_forums[ 'xxx' ] will be true if the use ticked the 'xxx' checkbox in the previous forums
*/
 
 
//Set the post-page on the DRW object
Line 474 ⟶ 515:
 
//Add new section to designated page
var edittoken = mw.user.tokens.get( 'editTokencsrfToken' );
 
var date = new Date();
Line 504 ⟶ 545:
}
 
function yesClickyesContentClick() {
gDRW.talkpage = true;
showStep2();
Line 510 ⟶ 551:
 
/**
* Taken almost verbatim from httphttps://www.mediawiki.org/wiki/API:Edit
*/
function addNewSection( pagetitle, summary, content, editToken ) {
Line 554 ⟶ 595:
if ( $( '#myDRW' ).length ){
 
//importStylesheet( 'UserMediaWiki:Steven Zhang/DRWGadget-DRN-wizard.css' ); //CSS Styles for the DRW
 
//Setup the App's workspace
$( '#myDRW' ).html( '' );
$( '#myDRW' ).append( $( '<div id="drw_main" style="height: 100%; width: 800px1000px; border : 2px black solid;"></div>' ) );
$( '#drw_main' ).append( '<div id="drwProgressBar" style="width: 750px950px; padding: 20px 25px; height: 30px; text-align: center"></div>' );
$( '#drw_main' ).append( '<div id="drwContent1" style="width: 700px900px; padding: 25px 50px"></div>' );
$( '#drw_main' ).append( '<div id="drwButtons" style="width: 700px900px; padding: 10px 50px; text-align: center"></div>' );
 
showStep1(); //Show the first page