MediaWiki:DRN-wizard.js: Difference between revisions

Content deleted Content added
tweak
per tper
 
(43 intermediate revisions by 14 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
*/
function drw() {
 
//Keep track of what step we are on
this.wizard_step = 0;
 
//Has the admin attempted to resolve this on the talk page
this.talkpage = false;
 
//Title of Article
this.article_title = '';
 
//Description of dispute
this.dispute_description = '';
 
//Involved users
this.involved_users = [mw.config.get( 'wgUserName' ) + ', '];
 
//Previous forums
this.previous_forums = '';
 
//Desired Outcome
this.desired_outcome = '';
 
//Page where the report will be posted
this.post_link = '';
 
// Draw text box
this.drawTitleInput = function() {
//Appends to $(" '#drwContent1"' )
 
$(" '#drwContent1"' ).append(" '<h3>Location of dispute</h3>"' );
$(" '#drwContent1"' ).append(" '<p>WhatPlease isprovide the ___locationname of thisthe dispute?article Ifor therepage arewhere multiplethe dispute is located.<br> For forumsexample, listif the main onedispute andwas describeon the othersarticle Australia, enter in <b>Australia</b> in the disputebox, not description.<nowiki>[[Australia]]</pnowiki>" or https://en.wikipedia.org/wiki/Australia' );
 
var inputbox = $( document.createElement( 'input' ) );
inputbox.attr( {
type: "'text"',
name: "'article_title"',
value: this.article_title
} });
 
inputbox.change( function() {
gDRW.article_title = this.value.replace(" 'https://"', "'http://"' ).replace(" 'http://en.wikipedia.org/wiki/"', ""'' ).replace(" '_"', "' ' ").replace(" '[["', '' ).replace(" ']]"', ''); } );
} );
 
$("#drwContent1").append( inputbox );
$( '#drwContent1' ).append( inputbox );
}
};
 
// Draw description textarea
// Draw description textarea
this.drawDescriptionInput = function() {
this.drawDescriptionInput = function() {
//Appends to $("#drwContent1")
//Appends to $( '#drwContent1' )
 
$("#drwContent1").append("<h3>Dispute overview</h3>");
$( '#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' ) );
desc.attr( {
rows: 6,
cols: 60,
maxlength: 2000
} });
desc.text( this.dispute_description );
 
desc.change( function() {
gDRW.dispute_description = this.value;
} );
desc.bindon( 'keyup', function() {
$(" '#taCount"' ).text("" '' + this.value.length +" ' / 2000"' );
} );
 
$(" '#drwContent1"' ).append( desc );
 
$(" '#drwContent1"' ).append( $(" '<p id='"taCount'>">' + this.dispute_description.length +" ' / 2000</p>"' ) );
};
}
 
// Involved users
this.drawUserInput = function() {
//Appends to $(" '#drwContent1"' )
 
$(" '#drwContent1"' ).append(" '<h3>Users involved</h3>"' );
$(" '#drwContent1"' ).append(" '<p>Who else is involved in the dispute? Enter them into the below box, without the User:, separated by commas: e.g. Example, Example2. (Please remember to notify them of this discussion)</p>"' );
 
var inputbox = $( document.createElement( 'input' ) );
inputbox.attr( {
type: "'text"',
name: "'involved_users"',
value: this.involved_users.join( ', ' )
} });
 
inputbox.change( function() { gDRW.involved_users = this.value; } );
gDRW.involved_users = this.value.split( ',' ).map( function ( involved_user ) { return involved_user.trim(); } );
} );
$("#drwContent1").append( inputbox );
 
}
$( '#drwContent1' ).append( inputbox );
};
// Draw previous forums
 
this.drawPreviousInput = function() {
// Draw previous forums
//Appends to $("#drwContent1")
this.drawPreviousInput = function() {
//Appends to $(" '#drwContent1").append("<h3>Resolving' the dispute </h3>");
 
$("#drwContent1").append("<p>What other steps, if any, have you tried to resolve this dispute?</p>");
$( '#drwContent1' ).append( '<h3>Resolving the dispute</h3>' );
$( '#drwContent1' ).append( '<p>What other steps have you tried to resolve the dispute so far. Please provide a link to where these discussions have occurred, separated by a comma or new line. For example:<br>' );
var desc = $( document.createElement('textarea') );
$( '#drwContent1' ).append('<ul>' +
desc.attr({
'<li><nowiki>[[Talk:Australia#Removal_of_Chief_Justice_from_Infobox]]</li>' +
rows: 3,
'<li><nowiki>[https://en.wikipedia.org/wiki/Talk:Australia#Removal_of_Chief_Justice_from_Infobox Talk:Australia]</li>' +
cols: 60,
'</ul>' );+
maxlength: 500
$( '#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>' );
});
 
desc.text( this.previous_forums );
var desc = $( document.createElement( 'textarea' ) );
desc.attr( {
desc.change( function() { gDRW.previous_forums = this.value; } );
rows: 3,
desc.bind('keyup', function() { $("#pcCount").text(""+this.value.length+" / 500"); });
cols: 60,
maxlength: 500
$("#drwContent1").append( desc );
} );
$("#drwContent1") desc.appendtext( $("<p id='pcCount'>"+this.previous_forums.length+"/500</p>") );
 
}
desc.change( function() {
gDRW.previous_forums = this.value;
// Draw outcome textarea
} );
this.drawOutcomeInput = function() {
desc.on( 'keyup', function() {
//Appends to $("#drwContent1")
$( '#pcCount' ).text( '' + this.value.length + ' / 500' );
} );
$("#drwContent1").append("<p>How do you think we can help resolve the dispute?</p>");
 
$( '#drwContent1' ).append( desc );
var desc = $( document.createElement('textarea') );
 
desc.attr({
$( '#drwContent1' ).append( $( '<p id="pcCount">' + this.previous_forums.length + ' / 500</p>' ) );
rows: 5,
};
cols: 60,
 
maxlength: 500
// Draw outcome textarea
});
this.drawOutcomeInput = function() {
desc.text( this.desired_outcome );
//Appends to $( '#drwContent1' )
 
desc.change( function() { gDRW.desired_outcome = this.value; } );
$( '#drwContent1' ).append( '<p>How do you think we can help resolve the dispute?</p>' );
desc.bind('keyup', function() { $("#ocCount").text(""+this.value.length+" / 500"); });
 
var desc = $( document.createElement( 'textarea' ) );
$("#drwContent1").append( desc );
desc.attr( {
$("#drwContent1").append( $("<p id='ocCount'>"+this.desired_outcome.length+"/500</p>") );
rows: 5,
}
cols: 60,
maxlength: 500
// Draw the summary content
} );
this.drawDRWSummary = function() {
desc.text( this.desired_outcome );
//Appends to $("#drwContent1")
 
desc.change( function() {
//$("#drwContent1").append(list);
gDRW.desired_outcome = this.value;
} );
//Article Title
desc.on( 'keyup', function() {
$("#drwContent1").append("<h3>Location of dispute</h3>");
$(" '#drwContent1").append(ocCount' $("<p></p>").text( '' + this.article_title)value.length + ' / 500' );
} );
 
//Dispute Description
$(" '#drwContent1"' ).append("<h3>Dispute overview</h3>"desc );
$(" '#drwContent1"' ).append( $(" '<p id="ocCount">' + this.desired_outcome.length + ' / 500</p>").text(this.dispute_description' ) );
};
 
//Users involved
// Draw the summary content
$("#drwContent1").append("<h3>Users involved</h3>");
this.drawDRWSummary = function() {
$("#drwContent1").append( $("<p></p>").text(this.involved_users) );
//Appends to $( '#drwContent1' )
 
//Previous forums
//$(" '#drwContent1"' ).append("<h3>Resolving thelist dispute</h3>");
 
$("#drwContent1").append("<h4>Other steps if any, you have tried to resolve this dispute</h4>");
//Article Title
$("#drwContent1").append( $("<p></p>").text(this.previous_forums) );
$( '#drwContent1' ).append( '<h3>Location of dispute</h3>' );
$( '#drwContent1' ).append( $( '<p></p>' ).text( this.article_title ) );
//Desired Outcome
 
$("#drwContent1").append("<h4>How you think we can help resolve the dispute?</h4>");
//Dispute Description
$("#drwContent1").append( $("<p></p>").text(this.desired_outcome) );
$( '#drwContent1' ).append( '<h3>Dispute overview</h3>' );
$( '#drwContent1' ).append( $( '<p></p>' ).text( this.dispute_description ) );
}
 
//Users involved
// Generate a WikiText string, representing the report.
$( '#drwContent1' ).append( '<h3>Users involved</h3>' );
// Returns a string of wikitext
$( '#drwContent1' ).append( $( '<p></p>' ).text( this.involved_users.join(', ') ) );
this.getWikitextReport = function() {
 
//Previous forums
//Title of dispute
$( '#drwContent1' ).append( '<h3>Resolving the dispute</h3>' );
report += "====<big> " + this.article_title + " </big>====\n";
$( '#drwContent1' ).append( '<h4>Previous steps to resolve the dispute</h4>' );
report += ":{{pagelinks|" + this.article_title +"}}\n";
$( '#drwContent1' ).append( $( '<p></p>' ).text( this.previous_forums ) );
 
//Returns string of wikitext for submission to DR page
//Desired Outcome
var report = "{{DR case status}}\n{{drn filing editor|{{subst:" + "REVISIONUSER}}}}\n{{subst:" + "DNAU|14}}<!-- PLEASE REMOVE THE PREVIOUS COMMENT WHEN CLOSING THIS THREAD. (Otherwise the thread won't be archived until the date shown.) -->\n\n";
$( '#drwContent1' ).append( '<h4>How you think we can help resolve the dispute?</h4>' );
$( '#drwContent1' ).append( $( '<p></p>' ).text( this.desired_outcome ) );
//Timestamp
 
report += "<big>'''{{" + "subst:#time:d F Y}}'''</big>\n\n";
};
 
//On Talk Page
// Generate a WikiText string, representing the report.
report += "<span style=\"font-size:110%\">'''Have you discussed this on a talk page?'''</span>\n";
// Returns a string of wikitext
report += "\n"+( (this.talkpage)?'Yes, I have discussed this issue on a talk page already.':'no' )+"\n\n";
this.getWikitextReport = function() {
//Returns string of wikitext for submission to DR page
//Article Title
var report = "{{DR case status}}\n{{subst:DNAU|28}}<!-- REMEMBER TO REMOVE THE PREVIOUS COMMENT WHEN CLOSING THIS THREAD! -->\n{{drn filing editor|{{subst:REVISIONUSER}}|~~~~~}}\n\n";
report += "<span style=\"font-size:110%\">'''Location of dispute'''</span>\n";
 
var articleArray = this.article_title.split(',');
//On Talk Page
for (var articleIndex = 0; articleIndex < articleArray.length; articleIndex++)
report += "<span style=\"font-size:110%\">'''Have you discussed this on a talk page?'''</span>\n";
{
report += '\n' + ( ( this.talkpage ) ? 'Yes, I have discussed this issue on a talk page already.' : 'no' ) + '\n\n';
report += "* {{pagelinks|" + articleArray[articleIndex]+"}}\n";
 
}
//Article Title
report += "<span style=\"font-size:110%\">'''Location of dispute'''</span>\n";
//Involved users
var articleArray = this.article_title.split( ',' );
report += "<span style=\"font-size:110%\">'''Users involved'''</span>\n";
for ( var articleIndex = 0; articleIndex < articleArray.length; articleIndex++ )
var userArray = this.involved_users.split(',');
{
for (var userIndex = 0; userIndex < userArray.length; userIndex++)
report += '* {{pagelinks|' + articleArray[ articleIndex ] + '}}\n';
{
}
report += "* {{User|" + userArray[userIndex]+"}}\n";
}
//Involved users
report += "<span style=\"font-size:110%\">'''Users involved'''</span>\n";
//Dispute Description
var userIndex;
report += "<span style=\"font-size:110%\">'''Dispute overview'''</span>\n";
for ( userIndex = 0; userIndex < this.involved_users.length; userIndex++ )
report += "\n"+ this.dispute_description+"\n\n";
{
var user = this.involved_users[ userIndex ];
//Previous forums
user = user.trim();
report += "<span style=\"font-size:110%\">'''Have you tried to resolve this previously?'''</span>\n";
if ( user ) {
report += "\n"+ this.previous_forums+"\n\n";
report += '* {{User|' + user + '}}\n';
}
//Desired Outcome
}
report += "<span style=\"font-size:110%\">'''How do you think we can help?'''</span>\n";
 
report += "\n" + this.desired_outcome+"\n\n";
//Dispute Description
report += "<span style=\"font-size:110%\">'''Dispute overview'''</span>\n";
//User statements
report += '\n'+ this.dispute_description + '\n\n';
var currentUser = mw.config.get( 'wgUserName' );
 
for (var userIndex = 0; userIndex < userArray.length; userIndex++)
//Previous forums
{
report += "<span style=\"font-size:110%\">'''How have you tried to resolve this dispute before coming here?'''</span>\n";
if ( userArray[userIndex] != currentUser) {
report += '\n'+ this.previous_forums + '\n\n';
report += "===== Opening comments by " + userArray[userIndex]+" =====\n<div style=\"font-size:smaller\">Please limit to 2000 characters - longer statements may be deleted in their entirety or asked to be shortened. This is so a volunteer can review the dispute in a timely manner. Thanks.</div>\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';
//Discussion
 
report += "===== Discussion =====\n<div style=\"font-size:smaller\">Please do not use this for discussing the dispute prior to a volunteer opening the thread for comments - continue discussing the issues on the article talk page if necessary.</div>";
//User statements
var currentUser = mw.config.get( 'wgUserName' );
return report;
for ( userIndex = 0; userIndex < this.involved_users.length; userIndex++ ) {
}
var user = this.involved_users[ userIndex ];
if ( user != currentUser ) {
// Returns an html string, representing the progress bar, based on the
report += '==== Summary of dispute by ' + 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";
// objects state.
}
this.getProgressBar = function() {
}
var s1_active =( this.wizard_step==1 )?' pr-active':'';
 
var s2_active =( this.wizard_step==2 )?' pr-active':'';
//Discussion
var s3_active =( this.wizard_step==3 )?' pr-active':'';
report += '=== ' + this.article_title + " discussion ===\n<div style=\"font-size:smaller\">Please keep discussion to a minimum before being opened by a volunteer. Continue on article talk page if necessary.</div>";
 
return report;
var signupbox = '<ul id="signuptopbox">';
};
signupbox += '<li class="s1'+s1_active+'"><span class="pr-number">1</span><span>Preliminary</span></li>';
 
signupbox += '<li class="pr-spacer'+s1_active+'"><div></div></li>';
// Returns an html string, representing the progress bar, based on the
// objects state.
signupbox += '<li class="s2'+s2_active+'"><span class="pr-number">2</span><span>Description</span></li>';
this.getProgressBar = function() {
signupbox += '<li class="pr-spacer'+s2_active+'"><div></div></li>';
var s1_active = ( this.wizard_step == 1 ) ? ' pr-active' : '';
var s2_active = ( this.wizard_step == 2 ) ? ' pr-active' : '';
signupbox += '<li class="s3'+s3_active+'"><span class="pr-number">3</span><span>Summary</span></li>';
var s3_active = ( this.wizard_step == 3 ) ? ' pr-active' : '';
signupbox += '<li class="pr-spacer'+s3_active+'"><div></div></li>';
var s4_active = ( this.wizard_step == 4 ) ? ' pr-active' : '';
 
signupbox += '</ul>';
 
var signupbox = '<ul id="signuptopbox">';
return signupbox;
signupbox += '<li class="s1' + s1_active + '"><span class="pr-number">1</span><span>Preliminary</span></li>';
}
signupbox += '<li class="pr-spacer' + s1_active + '"><div></div></li>';
 
this.getArticleTitle = function() {
signupbox += '<li class="s2' + s2_active + '"><span class="pr-number">2</span><span>Type of dispute</span></li>';
return this.article_title;
signupbox += '<li class="pr-spacer' + s2_active + '"><div></div></li>';
}
signupbox += '<li class="s2' + s3_active + '"><span class="pr-number">3</span><span>Description</span></li>';
this.getDisputeDescription = function() {
signupbox += '<li class="pr-spacer' + s3_active + '"><div></div></li>';
return this.dispute_description;
 
}
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>';
 
return signupbox;
};
 
this.getArticleTitle = function() {
return this.article_title;
};
 
this.getDisputeDescription = function() {
return this.dispute_description;
};
 
}
 
/**
* The various "show...()" functions display each of the 'screens' in the wizard
*/
 
function showStep1() {
 
gDRW.wizard_step = 1;
 
$(" '#drwProgressBar"' ).html( gDRW.getProgressBar() );
 
$( '#drwContent1' ).html(
$("#drwContent1").html('<h2>Request dispute resolution</h2> <p> Hi there. This form can be used to file a request at the Dispute Resolution Noticeboard. - a process for resolving a dispute 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="http://en.wikipedia.org/wiki/WP:ANI">here.</a> If you have any questions please ask one of our <a href="http://en.wikipedia.org/wiki/WP:DRVOLUNTEERS">volunteers</a> for guidance.\
'<h2>Request dispute resolution</h2>' +
\
 
\
'<p>' +
<h3>In brief: dispute resolution should be used when you:</h3>\
 
\
'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. ' +
<ul>\
'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="https://en.wikipedia.org/wiki/WP:ANI">here</a>. ' +
<li>Have a dispute with another editor and need help resolving it</li>\
'If you have any questions please ask one of our <a href="https://en.wikipedia.org/wiki/WP:DRVOLUNTEERS">volunteers</a> for guidance.' +
<li>Are willing to discuss the issues in a calm and civil manner</li>\
 
<li>Are open to the idea of compromising with the other editors to resolve the dispute</li>\
'<h3>In brief: dispute resolution should be used when you:</h3>' +
</ul>\
 
\
'<ul>' +
<h3>This process can:</h3>\
'<li>Have a dispute with another editor and need help resolving it</li>' +
<ul>\
'<li>Are willing to discuss the issues in a calm and civil manner</li>' +
<li>Help provide suggestions on content</li>\
'<li>Are open to the idea of compromising with the other editors to resolve the dispute</li>' +
<li>Frame discussions and offer support for parties that want to work towards a compromise</li>\
'</ul>\' +
 
\
'<h3>This process cannotcan:</h3>\' +
 
<ul>\
'<ul>' +
<li>Block other users from editing (either everywhere or specific pages)</li>\
'<li>Help provide suggestions on content</li>' +
<li>Remove content that you don\'t like from articles</li>\
'<li>Provide editors with guidance on applicable policies and guidelines to the dispute </li>' +
<li>Force another editor to do something</li>\
'<li>Mediate discussions and assist editors work towards a consensus on the disputed content</li>' +
<li>Address disputes that are currently under discussion somewhere else (such as <a href="http://enwp.org/WP:RFC">Requests for Comment</a>, <a href="http://enwp.org/WP:M">Mediation</a> or <a href="http://enwp.org/WP:RFAR">Arbitration</a>).</li>\
'<li>Provide a structured environment with oversight, to allow editors to work together with experienced input</li>' +
</p>\
'</ul>' +
<br>Has this issue been discussed extensively on the article talk page? (If you don\'t know what an article talk page is, answer "Not yet". </p>');
 
'<h3>This process cannot:</h3>' +
var buttons = '<a href="javascript:yesClick()" class="button1">Yes, it has.</a>';
 
buttons += ' <a href="javascript:showCancel()" class="button1">Not yet.</a>';
'<ul>' +
$("#drwButtons").html(buttons);
'<li>Block other users from editing (either everywhere or specific pages)</li>' +
'<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="https://en.wikipedia.org/wiki/WP:RFC">Requests for Comment</a> or <a href="https://en.wikipedia.org/wiki/WP:RFAR">Arbitration</a>)</li>' +
 
'</p>' +
 
'<p>Has this issue been discussed extensively on the article talk page? (If you don\'t know what an article talk page is, answer "Not yet".)</p>'
);
 
var buttons = '<a href="#top" class="button1" id="yesContentClickButton">Yes, it has.</a>';
buttons += ' <a href="#top" class="button1" id="showCancelButton">Not yet.</a>';
$( '#drwButtons' ).html( buttons );
 
$( '#yesContentClickButton' ).click( yesContentClick );
$( '#showCancelButton' ).click( showCancel );
}
 
function showStep2() {
 
function showStep2( errorMsg ) {
gDRW.wizard_step = 2;
 
gDRW.wizard_step = 2;
$(" '#drwProgressBar"' ).html( gDRW.getProgressBar() );
 
$( '#drwContent1' ).html(
var intro = '';
'<h2>Types of dispute</h2>' +
 
if ( typeof errorMsg !== 'undefined' ) {
'<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>'
intro = '<p class="warning">' + errorMsg + '</p>';
);
}
 
var buttons = '<a href="#top" class="button1" id="yesConductClickButton">Yes, it is about another user.</a>';
intro += '<p>Here, briefly describe the current situation - where the dispute is happening, what is the dispute and what are you hoping to get out of dispute resolution. (Basically, how can we help resolve the issue?)<br><br>Take note of the character limits as they are there to help focus the discussion.</p>';
buttons += ' <a href="#top" class="button1" id="showContentDisputeForm">No, it is not.</a>';
$(" '#drwContent1"drwButtons' ).html( introbuttons );
 
$( '#yesConductClickButton' ).click( showConductCancel );
gDRW.drawTitleInput();
$( '#showContentDisputeForm' ).click( showStep3 );
gDRW.drawDescriptionInput();
gDRW.drawUserInput();
gDRW.drawPreviousInput();
gDRW.drawOutcomeInput();
var buttons = '<a href="javascript:showStep1()" class="button1">Back</a>';
buttons += ' <a href="javascript:showCancel()" class="button1">Cancel</a>';
buttons += ' <a href="javascript:showStep3()" class="button1">Next</a>';
$("#drwButtons").html(buttons);
}
 
function showStep3( errorMsg ) {
 
gDRW.wizard_step = 3;
var inputErrors = [];
$( '#drwProgressBar' ).html( gDRW.getProgressBar() );
 
//Check that vars were filled
var intro = '';
if (gDRW.article_title == '') {
 
inputErrors.push("Location of dispute");
if ( typeof errorMsg === 'string' ) {
}
intro = '<p class="warning">' + errorMsg + '</p>';
if (gDRW.dispute_description == '') {
}
inputErrors.push("Dispute overview");
 
}
intro +=
if (gDRW.previous_forums == '') {
'<p>' +
inputErrors.push("Previous steps");
'Here, briefly describe the current situation - where the dispute is happening, what is the dispute and what are you hoping to get out of dispute resolution. ' +
}
'(Basically, how can we help resolve the issue?)' +
if (gDRW.desired_outcome == '') {
'</p>' +
inputErrors.push("Desired outcome");
'<p>' +
}
'Take note of the character limits as they are there to help focus the discussion.' +
if ( inputErrors.length > 0 ) {
'</p>';
return showStep2( 'All fields are required. Missing values for: '+inputErrors.join(', ') );
 
}
$( '#drwContent1' ).html( intro );
 
gDRW.wizard_step = 3;
gDRW.drawTitleInput();
$("#drwProgressBar").html( gDRW.getProgressBar() );
 
gDRW.drawDescriptionInput();
$("#drwContent1").html('<p>Here\'s a summary of what you\'ve told us. Quickly check that it\'s all correct before you submit your request, and we will file the dispute for you and give you a link to the discussion.</p>');
 
gDRW.drawDRWSummarydrawUserInput();
 
gDRW.drawPreviousInput();
 
var buttons = '<a href="javascript:showStep2()" class="button1">Edit</a>';
gDRW.drawOutcomeInput();
buttons += ' <a href="javascript:showCancel()" class="button1">Cancel</a>';
 
buttons += ' <a href="javascript:doSubmit()" class="button1">Save</a>';
var buttons = '<a href="#top" class="button1" id="showStep1Button">Back</a>';
buttons += ' <a href="#top" class="button1" id="showCancelButton">Cancel</a>';
$("#drwButtons").html(buttons);
buttons += ' <a href="#top" class="button1" id="showStep4Button">Next</a>';
 
$( '#drwButtons' ).html( buttons );
 
$( '#showStep1Button' ).click( showStep1 );
$( '#showCancelButton' ).click( showCancel );
$( '#showStep4Button' ).click( showStep4 );
}
 
function showStep4() {
 
var inputErrors = [];
 
//Check that vars were filled
if ( gDRW.article_title === '' ) {
inputErrors.push( 'Location of dispute' );
}
if ( gDRW.dispute_description === '' ) {
inputErrors.push( 'Dispute overview' );
}
if ( gDRW.previous_forums === '' ) {
inputErrors.push( 'Previous steps' );
}
if ( gDRW.desired_outcome === '' ) {
inputErrors.push( 'Desired outcome' );
}
if ( inputErrors.length > 0 ) {
return showStep3( 'All fields are required. Missing values for: ' + inputErrors.join( ', ' ) );
}
 
gDRW.wizard_step = 4;
$( '#drwProgressBar' ).html( gDRW.getProgressBar() );
 
$( '#drwContent1' ).html( '<p>Here\'s a summary of what you\'ve told us. Quickly check that it\'s all correct before you submit your request, and we will file the dispute for you and give you a link to the discussion.</p>' );
 
gDRW.drawDRWSummary();
 
 
var buttons = '<a href="#top" class="button1" id="showStep3Button">Edit</a>';
buttons += ' <a href="#top" class="button1" id="showCancelButton">Cancel</a>';
buttons += ' <a href="#top" class="button1" id="doSubmitButton">Save</a>';
 
$( '#drwButtons' ).html( buttons );
 
$( '#showStep3Button' ).click( showStep3 );
$( '#showCancelButton' ).click( showCancel );
$( '#doSubmitButton' ).click( doSubmit );
}
 
function showResult( status ) {
 
$(" '#drwProgressBar"' ).text( '' );
 
if ( status == 'ok' ) {
//Show thankyou
$(" '#drwContent1"' ).html( '<h3>Success!</h3><p>Thank you for filing a request for dispute resolution</p>' );
$(" '#drwContent1"' ).append( $(" '<a>Click here to go view your request.</a>"' ).attr( { href: mw.config.get( 'wgArticlePath' ).replace( '$1', gDRW.post_link ) } ) );
$(" '#drwButtons"' ).html( '' );
} else if ( status == 'error' ) {
//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="javascript:showStep3()#top" class="button1" id="showStep4Button">Back to Summary</a>' );
$( '#showStep4Button' ).click( showStep4 );
} else {
} else {
$("#drwContent1").html('<h2>Error</p><p>Something went wrong!</p>');
$( '#drwContent1' ).html( '<h2>Error</p><p>Something went wrong!</p>' );
$("#drwButtons").html('');
$( '#drwButtons' ).html( '' );
}
}
}
 
function showCancel() {
 
gDRW.wizard_step = 0;
$(" '#drwProgressBar"' ).html( gDRW.getProgressBar() );
 
$( '#drwContent1' ).html(
$("#drwContent1").html('<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="http://en.wikipedia.org/wiki/WP:DISCUSSIT">this page,</a>\ or you can place <code><nowiki>{{helpme}}</nowiki></code> on <a href="http://enwp.org/Special:MyTalk">your own talk page</a>, and a volunteer will come by your page to help.<br><br> If you have already tried to discuss this issue already and have received <b>no</b> response from others, you may go back to the previous page and file a request - but this must only be done if you have attempted to discuss the issue first.</a>\</p>');
'<p>' +
$("#drwButtons").html('<a href="javascript:showStep1()" class="button1">Start Over</a>');
'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="https://en.wikipedia.org/wiki/WP:DISCUSSIT">this page,</a> or you can place <code>{{helpme}}</code> on <a href="https://en.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>'
);
$( '#drwButtons' ).html( '<a href="#top" class="button1" id="showStep1Button">Start Over</a>' );
$( '#showStep1Button' ).click( showStep1 );
}
 
/**
* Do the final step of the DRW and post the report to the appropriate page
*/
function doSubmit() {
 
//Notify user that we are doing the update
$(" '#drwProgressBar"' ).html( '<div style="text-align: center"><img alt="saving report" src="https://upload.wikimedia.org/wikipedia/commons/d/de/Ajax-loader.gif"></img></div>' );
$(" '#drwContent1"' ).html( '<p>Posting Report....</p>' );
 
//Decide on the page to update
var DRPage = 'Wikipedia:Dispute_resolution_noticeboard'; //The default page to post this
 
/**
* Decide where to post this dispute resolution report. In the end, DRPage needs to hold
* the title of the page where we post the report.
*
* gDRW.dispute_type is set the short name (index) of the user-selected dispute type
* 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
gDRW.post_link = DRPage + '#' + gDRW.article_title.replace( ' ', '_' );
//Set the post-page on the DRW object
 
gDRW.post_link = DRPage + "/" + gDRW.article_title.replace(' ', '_');
//Compose Report
var report = gDRW.getWikitextReport();
//Compose Report
 
var report = gDRW.getWikitextReport();
//Add new section to designated page
var edittoken = mw.user.tokens.get( 'csrfToken' );
//Add new section to designated page
 
var edittoken = mw.user.tokens.get( 'editToken' );
var date = new Date();
var dateString var= date=new Date.toLocaleDateString();
var summary = gDRW.article_title;
var dateString=date.toLocaleDateString();
 
var summary = gDRW.article_title;
addNewSection( DRPage, summary, report, edittoken );
addNewSubPage( DRPage, summary, report, edittoken );
}
 
 
/**
* Event handler functions
*/
function setDisputeForum( box ) {
//alert(" 'Setting "' + gDRW.forum_labels[ box.value ] +" ' to true"' );
gDRW.previous_forums[ box.value ] = box.checked;
 
var linkboxid = "'link_"' + box.value;
 
if ( box.checked ) {
$(" '#"' + linkboxid ).show();
} else {
$(" '#"' + linkboxid ).hide();
}
}
}
 
function updateLink( box ) {
gDRW.forum_links[ box.name ] = box.value;
}
 
function yesClickyesContentClick() {
gDRW.talkpage = true;
showStep2();
}
 
/**
* Taken almost verbatim from httphttps://www.mediawiki.org/wiki/API:Edit
*/
function addNewSubPageaddNewSection( pagetitle, summary, content, editToken ) {
$.ajax( {
url: mw.util.wikiScript( 'api' ),
data: {
format: 'json',
action: 'edit',
title: pagetitle + '/' + summary,
section: 'new',
summary: summary,
summary: summary,
text: content,
text: content,
token: editToken
token: editToken
},
},
dataType: 'json',
type dataType: 'POSTjson',
type: 'POST',
success: function( data ) {
success: function( data ) {
if ( data && data.edit && data.edit.result == 'Success' ) {
//window.___location.reload(); // reload page if edit was successful
showResult( 'ok' );
} else if ( data && data.error ) {
alert( 'Error: API returned error code "' + data.error.code + '": ' + data.error.info );
showResult( 'error' );
} else {
alert( 'Error: Unknown result from API.' );
showResult( 'error2' );
}
}
},
},
error: function( xhr ) {
alert( 'Error: Request failed.' );
}
}
} });
}
 
 
/**
* Initialization function. Test if we should place the DRW on the current page.
* Looks for a <div id="myDRW"></div> on the page.
*/
 
function runDRW() {
 
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: 600px100%; width: 800px1000px; border : 2px black solid;"></div>' ) );
$( '#drw_main' ).append( '<div id="drwProgressBar" style="width: 950px; padding: 20px 25px; height: 30px; text-align: center"></div>' );
$("#drw_main").css('height', '1000px');
$(" '#drw_main"' ).append( '<div id="drwContent1" style="width: 750px900px; padding: 20px 25px; height: 30px; text-align: center" id="drwProgressBar50px"></div>' );
$(" '#drw_main"' ).append( '<div id="drwButtons" style="width: 700px900px; padding: 25px10px 50px"; id="drwContent1text-align: center"></div>' );
 
$("#drw_main").append('<div style="width: 700px; padding: 10px 50px; text-align: center" id="drwButtons"></div>');
showStep1(); //Show the first page
}
showStep1(); //Show the first page
}
}
 
};
 
var gDRW = new drw();
 
$( document ).ready( runDRW() );
// JavaScript Document
 
// </nowiki>